Re: kernel BUG at lib/lockref.c:LINE!

From: Al Viro
Date: Mon Jul 08 2019 - 16:29:55 EST


On Mon, Jul 08, 2019 at 12:37:06PM -0700, syzbot wrote:
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit: d58b5ab9 Add linux-next specific files for 20190708
> git tree: linux-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=123d6887a00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=bf9882946ecc11d9
> dashboard link: https://syzkaller.appspot.com/bug?extid=f70e9b00f8c7d4187bd0
> compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=173375c7a00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1536f9bfa00000
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+f70e9b00f8c7d4187bd0@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> ------------[ cut here ]------------
> kernel BUG at lib/lockref.c:189!

Mea culpa... It's "Teach shrink_dcache_parent() to cope with mixed-filesystem
shrink lists", and the fix should be simply this:

diff --git a/fs/dcache.c b/fs/dcache.c
index d8732cf2e302..d85d8f2c8c97 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1555,6 +1555,7 @@ void shrink_dcache_parent(struct dentry *parent)
d_walk(parent, &data, select_collect2);
if (data.victim) {
struct dentry *parent;
+ spin_lock(&data.victim->d_lock);
if (!shrink_lock_dentry(data.victim)) {
rcu_read_unlock();
} else {