Re: kernel BUG at fs/inode.c:LINE!

From: Al Viro
Date: Mon Dec 17 2018 - 02:22:06 EST

On Sun, Dec 16, 2018 at 10:11:04PM -0800, syzbot wrote:
> Hello,
> syzbot found the following crash on:
> HEAD commit: d14b746c6c1c Add linux-next specific files for 20181214
> git tree: linux-next
> console output:
> kernel config:
> dashboard link:
> compiler: gcc (GCC) 8.0.1 20180413 (experimental)
> syz repro:
> C reproducer:
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+5399ed0832693e29f392@xxxxxxxxxxxxxxxxxxxxxxxxx
> slab_pre_alloc_hook mm/slab.h:423 [inline]
> slab_alloc mm/slab.c:3365 [inline]
> kmem_cache_alloc+0x2c4/0x730 mm/slab.c:3539
> __d_alloc+0xc8/0xb90 fs/dcache.c:1599
> ------------[ cut here ]------------
> kernel BUG at fs/inode.c:1566!
> d_alloc_anon fs/dcache.c:1698 [inline]
> d_make_root+0x43/0xc0 fs/dcache.c:1885
> autofs_fill_super+0x6f1/0x1c30 fs/autofs/inode.c:273

Huh? BUG is in iput(), AFAICS, so the stack trace is rather misreported.
iput() can be called by d_make_root(), provided that dentry allocation
fails. So the most straightforward interpretation would be that we
had an allocation failure (injected?), followed by iput() of the inode
passed to d_make_root(). Which happened to find I_CLEAR in ->i_state
of that inode somehow, which should be impossible short of seriously
buggered inode refcounting somewhere - the inode has just been returned
by new_inode(), which clears i_state, and it would have to have passed
clear_inode() (i.e. has been through inode eviction) since then...