Re: [PATCH] nilfs2: fix use-after-free bug in nilfs_mdt_destroy()

From: Al Viro
Date: Mon Aug 15 2022 - 22:41:00 EST


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...