linux/include
Prasanna Kumar Kalever 6497ef8df5 nbd: provide a way for userspace processes to identify device backends
Problem:
On reconfigure of device, there is no way to defend if the backend
storage is matching with the initial backend storage.

Say, if an initial connect request for backend "pool1/image1" got
mapped to /dev/nbd0 and the userspace process is terminated. A next
reconfigure request within NBD_ATTR_DEAD_CONN_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 -9 rbd-nbd
$ 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:
Provide a way for userspace processes to keep some metadata to identify
between the device and the backend, so that when a reconfigure request is
made, we can compare and avoid such dangerous operations.

With this solution, as part of the initial connect request, backend
path can be stored in the sysfs per device config, so that on a reconfigure
request it's easy to check if the backend path matches with the initial
connect backend path.

Please note, ioctl interface to nbd will not have these changes, as there
won't be any reconfigure.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20210429102828.31248-1-prasanna.kalever@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-06-30 15:34:04 -06:00
..
acpi Device properties framework updates for 5.14-rc1 2021-06-29 14:04:37 -07:00
asm-generic Merge branch 'akpm' (patches from Andrew) 2021-06-29 17:29:11 -07:00
clocksource clocksource/drivers/timer-ti-dm: Save and restore timer TIOCP_CFG 2021-06-15 14:14:14 +02:00
crypto crypto: api - Move crypto attr definitions out of crypto.h 2021-06-24 14:51:35 +08:00
drm
dt-bindings dt-bindings: connector: Add PD rev 2.0 VDO definition 2021-06-04 11:43:01 +02:00
keys
kunit kunit: make test->lock irq safe 2021-06-29 10:53:46 -07:00
kvm KVM: arm64: vgic: Implement SW-driven deactivation 2021-06-01 10:46:00 +01:00
linux for-5.14/drivers-2021-06-29 2021-06-30 12:21:16 -07:00
math-emu
media media: Fix Media Controller API config checks 2021-06-24 14:26:00 +02:00
memory
misc
net net: inline function get_net_ns_by_fd if NET_NS is disabled 2021-06-15 11:00:45 -07:00
pcmcia
ras
rdma
scsi
soc mbox: add polarfire soc system controller mailbox 2021-06-26 12:06:48 -05:00
sound ASoC: Fixes for v5.13 2021-05-25 08:58:01 +02:00
target
trace Merge branch 'akpm' (patches from Andrew) 2021-06-29 17:29:11 -07:00
uapi nbd: provide a way for userspace processes to identify device backends 2021-06-30 15:34:04 -06:00
vdso
video
xen xen/arm: move xen_swiotlb_detect to arm/swiotlb-xen.h 2021-05-14 15:52:05 +02:00