]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rbd: check for EOD after exclusive lock is ensured to be held
authorIlya Dryomov <idryomov@gmail.com>
Wed, 7 Jan 2026 21:37:55 +0000 (22:37 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 3 Feb 2026 20:00:22 +0000 (21:00 +0100)
commitbd3884a204c3b507e6baa9a4091aa927f9af5404
tree874ddca9685bde4c35d59695a4a4a614fd5fd4ac
parent18f7fcd5e69a04df57b563360b88be72471d6b62
rbd: check for EOD after exclusive lock is ensured to be held

Similar to commit 870611e4877e ("rbd: get snapshot context after
exclusive lock is ensured to be held"), move the "beyond EOD" check
into the image request state machine so that it's performed after
exclusive lock is ensured to be held.  This avoids various race
conditions which can arise when the image is shrunk under I/O (in
practice, mostly readahead).  In one such scenario

    rbd_assert(objno < rbd_dev->object_map_size);

can be triggered if a close-to-EOD read gets queued right before the
shrink is initiated and the EOD check is performed against an outdated
mapping_size.  After the resize is done on the server side and exclusive
lock is (re)acquired bringing along the new (now shrunk) object map, the
read starts going through the state machine and rbd_obj_may_exist() gets
invoked on an object that is out of bounds of rbd_dev->object_map array.

Cc: stable@vger.kernel.org
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Dongsheng Yang <dongsheng.yang@linux.dev>
drivers/block/rbd.c