Re: [PATCH] nilfs2: fix use-after-free bug in nilfs_mdt_destroy()
From: Ryusuke Konishi
Date: Tue Aug 16 2022 - 02:49:57 EST
On Tue, Aug 16, 2022 at 8:04 AM Al Viro wrote:
>
> On Tue, Aug 16, 2022 at 05:34:12AM +0900, Ryusuke Konishi wrote:
>
> > Yes, I agree it's better if security_inode_alloc() is moved to the end as
> > possible in the sense of avoiding similar issues.
> > But, would that vfs change be safe to backport to stable trees?
>
> Yes.
>
> > It looks like the error handling for security_inode_alloc() is in the
> > middle of inode_init_always() for a very long time..
>
> Look at the initializations done after it. The only thing with effects
> outside of inode itself is (since 2010) an increment of nr_inodes.
>
> > If you want to see the impact of the vfs change, I think it's one way
> > to apply this one in advance. Or if you want to fix it in one step,
> > I think it's good too. How do you feel about this ?
>
> IMO that should go into inode_init_always(), with Cc:stable. If you
> (or Dongliang Mu, or anybody else) would post such variant with
> reasonable commit message, I'll pick it into vfs.git and feed to Linus
> in the next window. E.g. into #work.inode, with that branch being
> made never-rebased, so that you could pull it into your development
> branch as soon as it's there...
I agree with your thoughts on the course of action.
Andrew, I withdraw this patch.
Dongliang (or Jiacheng?), would it be possible for you to post a revised patch
against inode_init_always() that moves the call of security_inode_alloc()
instead of i_private initialization (as Al Viro said in a nearby thread [1]) ?
If you have time, I would like to leave it to you since you wrote the
original patch for inode_init_always().
[1] https://lkml.kernel.org/r/CAO4S-mficMz1mQW06EuCF+o11+mRDiCpufqVfoHkcRbQbs8kVw@xxxxxxxxxxxxxx
Thanks,
Ryusuke Konishi