Skip to content
Commit 3ce6e1f6 authored by Tetsuo Handa's avatar Tetsuo Handa Committed by Jens Axboe
Browse files

loop: reintroduce global lock for safe loop_validate_file() traversal



Commit 6cc8e743 ("loop: scale loop device by introducing per
device lock") re-opened a race window for NULL pointer dereference at
loop_validate_file() where commit 310ca162 ("block/loop: Use
global lock for ioctl() operation.") has closed.

Although we need to guarantee that other loop devices will not change
during traversal, we can't take remote "struct loop_device"->lo_mutex
inside loop_validate_file() in order to avoid AB-BA deadlock. Therefore,
introduce a global lock dedicated for loop_validate_file() which is
conditionally taken before local "struct loop_device"->lo_mutex is taken.

Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Fixes: 6cc8e743 ("loop: scale loop device by introducing per device lock")
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 7054133d
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment