Re: possible deadlock in blkdev_put

From: David Sterba
Date: Tue Sep 22 2020 - 07:02:20 EST


On Tue, Sep 22, 2020 at 11:16:42AM +0200, Jan Kara wrote:
> Looks like btrfs issue. Adding relevant people to CC.

Thanks.

> On Mon 21-09-20 02:32:21, syzbot wrote:
> > Hello,
> >
> > syzbot found the following issue on:
> >
> > HEAD commit: 325d0eab Merge branch 'akpm' (patches from Andrew)
> > git tree: upstream
> > console output: https://syzkaller.appspot.com/x/log.txt?x=102425d9900000
> > kernel config: https://syzkaller.appspot.com/x/.config?x=b12e84189082991c
> > dashboard link: https://syzkaller.appspot.com/bug?extid=84a0634dc5d21d488419
> > compiler: gcc (GCC) 10.1.0-syz 20200507
> >
> > Unfortunately, I don't have any reproducer for this issue yet.
> >
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+84a0634dc5d21d488419@xxxxxxxxxxxxxxxxxxxxxxxxx
> >
> > ======================================================
> > WARNING: possible circular locking dependency detected
> > 5.9.0-rc5-syzkaller #0 Not tainted
> > ------------------------------------------------------
> > syz-executor.0/6878 is trying to acquire lock:
> > ffff88804c17d780 (&bdev->bd_mutex){+.+.}-{3:3}, at: blkdev_put+0x30/0x520 fs/block_dev.c:1804
> >
> > but task is already holding lock:
> > ffff8880908cfce0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: close_fs_devices.part.0+0x2e/0x800 fs/btrfs/volumes.c:1159
> >
> > which lock already depends on the new lock.

That matches what "btrfs: move btrfs_rm_dev_replace_free_srcdev outside
of all locks" fixes, among other syzbot reports.

On the way to master:
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git/commit/?h=next-fixes&id=d1db82c9a34451e8c0288315b51d9a67fb8eff95