linux/drivers/block
Ilya Dryomov 73679f8c45 rbd: retrieve and check lock owner twice before blocklisting
commit 588159009d upstream.

An attempt to acquire exclusive lock can race with the current lock
owner closing the image:

1. lock is held by client123, rbd_lock() returns -EBUSY
2. get_lock_owner_info() returns client123 instance details
3. client123 closes the image, lock is released
4. find_watcher() returns 0 as there is no matching watcher anymore
5. client123 instance gets erroneously blocklisted

Particularly impacted is mirror snapshot scheduler in snapshot-based
mirroring since it happens to open and close images a lot (images are
opened only for as long as it takes to take the next mirror snapshot,
the same client instance is used for all images).

To reduce the potential for erroneous blocklisting, retrieve the lock
owner again after find_watcher() returns 0.  If it's still there, make
sure it matches the previously detected lock owner.

Cc: stable@vger.kernel.org # f38cb9d9c204: rbd: make get_lock_owner_info() return a single locker or NULL
Cc: stable@vger.kernel.org # 8ff2c64c9765: rbd: harden get_lock_owner_info() a bit
Cc: stable@vger.kernel.org
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-03 10:24:17 +02:00
..
aoe
drbd drbd: correctly submit flush bio on barrier 2023-05-11 23:03:39 +09:00
mtip32xx
null_blk null_blk: Fix: memory release when memory_backed=1 2023-06-28 11:12:39 +02:00
paride
rnbd block/rnbd: replace REQ_OP_FLUSH with REQ_OP_WRITE 2023-06-09 10:34:09 +02:00
xen-blkback
zram
amiflop.c
ataflop.c
brd.c brd: use radix_tree_maybe_preload instead of radix_tree_preload 2023-03-10 09:34:34 +01:00
floppy.c
Kconfig
loop.c loop: LOOP_CONFIGURE: send uevents for partitions 2023-04-06 12:10:47 +02:00
Makefile
n64cart.c
nbd.c nbd: Fix debugfs_create_dir error checking 2023-06-09 10:34:09 +02:00
pktcdvd.c
ps3disk.c
ps3vram.c
rbd_types.h
rbd.c rbd: retrieve and check lock owner twice before blocklisting 2023-08-03 10:24:17 +02:00
sunvdc.c block: sunvdc: add check for mdesc_grab() returning NULL 2023-03-22 13:33:47 +01:00
swim_asm.S
swim.c
swim3.c
ublk_drv.c ublk: fail to recover device if queue setup is interrupted 2023-08-03 10:24:07 +02:00
virtio_blk.c
xen-blkfront.c xen/blkfront: Only check REQ_FUA for writes 2023-06-21 16:00:53 +02:00
z2ram.c