Re: [syzbot] general protection fault in list_lru_add
From: Muchun Song
Date: Sun Mar 27 2022 - 01:28:06 EST
On Sat, Mar 26, 2022 at 4:29 AM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, Mar 25, 2022 at 2:52 AM Muchun Song <songmuchun@xxxxxxxxxxxxx> wrote:
> >
> > We can see that we put the dentry (ffff88807ebda0f8) into
> > the list_lru (ffff888011bd47f0). But we do not allocate struct
> > list_lru_one for the memcg (ffff88801c530000). Then it panics.
>
> Hmm.
>
> Looking at memcg_slab_pre_alloc_hook(), I note that it will return
> success without doing the LRU checking for several cases.
>
> So since you can reproduce the problem, I would suggest you add some
> debug code to __d_alloc() that prints out something big if it gets a
> dentry but you can't look up the list_lru_one() for that dentry.
>
> Hmm?
>
> The only other situation I can think of is if dentry->d_sb were to
> change during the dentry lifetime, but I don't think that can happen.
> The only assignment I can find with "git grep" is that
>
> dentry->d_sb = sb;
>
> in __d_alloc(), and while it's possible my grep pattern was bogus, it
> sounds unlikely.
>
I have found the root cause, it was caused by kfence. Here is
the fix patch [1].
[1] https://lore.kernel.org/all/20220327051853.57647-1-songmuchun@xxxxxxxxxxxxx/
Thanks.