• Tetsuo Handa's avatar
    loop: reintroduce global lock for safe loop_validate_file() traversal · 3ce6e1f6
    Tetsuo Handa authored
    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>
    3ce6e1f6
loop.c 65.1 KB