Commit b0477a07 authored by OGAWA Hirofumi's avatar OGAWA Hirofumi Committed by Bart Van Assche
Browse files

UPSTREAM: loop: Fix ABBA locking race



Current loop calls vfs_statfs() while holding the q->limits_lock. If
FS takes some locking in vfs_statfs callback, this may lead to ABBA
locking bug (at least, FAT fs has this issue actually).

So this patch calls vfs_statfs() outside q->limits_locks instead,
because looks like no reason to hold q->limits_locks while getting
discord configs.

Chain exists of:
  &sbi->fat_lock --> &q->q_usage_counter(io)#17 --> &q->limits_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&q->limits_lock);
                               lock(&q->q_usage_counter(io)#17);
                               lock(&q->limits_lock);
  lock(&sbi->fat_lock);

 *** DEADLOCK ***

Reported-by: default avatar <syzbot+a5d8c609c02f508672cc@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=a5d8c609c02f508672cc


Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
Change-Id: Iece15e4e6aaec8e7d294aefc6d3f983fd5c4e149
Signed-off-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
(cherry picked from commit b4912557)
Signed-off-by: default avatarBart Van Assche <bvanassche@google.com>
parent 49d8530d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment