ceph-csi/internal/rbd
Prasanna Kumar Kalever 3686b6da8b rbd: utilize cookie support from rbd for nbd
Problem:
On remap/attach of device (i.e. nodeplugin restart), there is no way
for rbd-nbd to defend if the backend storage is matching with the initial
backend storage.

Say, if an initial map request for backend "pool1/image1" got mapped to
/dev/nbd0 and the userspace process is terminated (on nodeplugin restart).
A next remap/attach (nodeplugin start) request within reattach-timeout is
allowed to use /dev/nbd0 for a different backend "pool1/image2"

For example, an operation like below could be dangerous:

$ sudo rbd-nbd map --try-netlink rbd-pool/ext4-image
/dev/nbd0
$ sudo blkid /dev/nbd0
/dev/nbd0: UUID="bfc444b4-64b1-418f-8b36-6e0d170cfc04" TYPE="ext4"
$ sudo pkill -15 rbd-nbd   <-- nodeplugin terminate
$ sudo rbd-nbd attach --try-netlink --device /dev/nbd0 rbd-pool/xfs-image
/dev/nbd0
$ sudo blkid /dev/nbd0
/dev/nbd0: UUID="d29bf343-6570-4069-a9ea-2fa156ced908" TYPE="xfs"

Solution:
rbd-nbd/kernel now provides a way to keep some metadata in sysfs to identify
between the device and the backend, so that when a remap/attach request is
made, rbd-nbd can compare and avoid such dangerous operations.

With the provided solution, as part of the initial map request, backend
cookie (ceph-csi VOLID) can be stored in the sysfs per device config, so
that on a remap/attach request rbd-nbd will check and validate if the
backend per device cookie matches with the initial map backend with the help
of cookie.

At Ceph-csi we use VOLID as device cookie, which will be unique, we pass
the VOLID as cookie at map and use the same at the time of attach, that
way rbd-nbd can identify backends and their matching devices.

Requires:
https://github.com/ceph/ceph/pull/41323
https://lkml.org/lkml/2021/4/29/274

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2021-11-04 03:20:59 +00:00
..
clone.go rbd: modify copyEncryptionConfig to accept copyOnlyPassphrase arg 2021-10-05 07:46:57 +00:00
controllerserver_test.go cleanup: resolve parallel test issue 2021-07-13 11:31:39 +00:00
controllerserver.go rbd: split the parsing and deletion logic to its own functions. 2021-10-27 18:35:00 +00:00
driver.go rbd: detect krbd features in runtime and fallback to nbd 2021-11-01 08:17:36 +00:00
encryption.go rbd: modify copyEncryptionConfig to accept copyOnlyPassphrase arg 2021-10-05 07:46:57 +00:00
errors.go rbd: detect migration volID in DeleteVolume() and delete rbd image 2021-10-04 16:06:31 +00:00
identityserver.go internal: reformat long lines in internal/rbd package to 120 chars 2021-06-28 14:43:49 +00:00
migration_test.go rbd: change iteration variable name in the migration test to be specific 2021-10-11 10:06:30 +00:00
migration.go rbd: split the parsing and deletion logic to its own functions. 2021-10-27 18:35:00 +00:00
mirror.go rbd: add helper function to get local state 2021-08-16 17:38:25 +00:00
nodeserver_test.go cleanup: generalize the parseBool function 2021-11-01 08:17:36 +00:00
nodeserver.go rbd: provide a way to disable the auto fallback to nbd mounter 2021-11-01 08:17:36 +00:00
rbd_attach.go rbd: utilize cookie support from rbd for nbd 2021-11-04 03:20:59 +00:00
rbd_healer.go util: NewK8sClient() should not panic on non-Kubernetes clusters 2021-09-02 11:22:14 +00:00
rbd_journal.go rbd: modify copyEncryptionConfig to accept copyOnlyPassphrase arg 2021-10-05 07:46:57 +00:00
rbd_util_test.go rbd: detect krbd features in runtime and fallback to nbd 2021-11-01 08:17:36 +00:00
rbd_util.go rbd: detect krbd features in runtime and fallback to nbd 2021-11-01 08:17:36 +00:00
replicationcontrollerserver_test.go rbd: check local image state for resyncing 2021-10-26 12:00:36 +00:00
replicationcontrollerserver.go cleanup: remove FIXME from ResyncVolume 2021-10-26 12:00:36 +00:00
snapshot.go cleanup: move log functions to new internal/util/log package 2021-08-26 09:34:05 +00:00