lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHC9VhQgS1n5RJxFmVxohng9UL_Wi6x_0MOaPAeiFTFsUxZd0A@mail.gmail.com>
Date: Tue, 17 Dec 2024 11:44:21 -0500
From: Paul Moore <paul@...l-moore.com>
To: Song Liu <song@...nel.org>
Cc: linux-fsdevel@...r.kernel.org, linux-doc@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-btrfs@...r.kernel.org, 
	linux-xfs@...r.kernel.org, linux-security-module@...r.kernel.org, 
	willy@...radead.org, corbet@....net, clm@...com, josef@...icpanda.com, 
	dsterba@...e.com, brauner@...nel.org, jack@...e.cz, cem@...nel.org, 
	djwong@...nel.org, jmorris@...ei.org, serge@...lyn.com, fdmanana@...e.com, 
	johannes.thumshirn@....com
Subject: Re: [RFC] lsm: fs: Use i_callback to free i_security in RCU callback

On Mon, Dec 16, 2024 at 8:24 PM Song Liu <song@...nel.org> wrote:
> On Mon, Dec 16, 2024 at 4:22 PM Paul Moore <paul@...l-moore.com> wrote:
> >
> > On Mon, Dec 16, 2024 at 6:43 PM Song Liu <song@...nel.org> wrote:
> > >
> > > inode->i_security needes to be freed from RCU callback. A rcu_head was
> > > added to i_security to call the RCU callback. However, since struct inode
> > > already has i_rcu, the extra rcu_head is wasteful. Specifically, when any
> > > LSM uses i_security, a rcu_head (two pointers) is allocated for each
> > > inode.
> > >
> > > Add security_inode_free_rcu() to i_callback to free i_security so that
> > > a rcu_head is saved for each inode. Special care are needed for file
> > > systems that provide a destroy_inode() callback, but not a free_inode()
> > > callback. Specifically, the following logic are added to handle such
> > > cases:
> > >
> > >  - XFS recycles inode after destroy_inode. The inodes are freed from
> > >    recycle logic. Let xfs_inode_free_callback() and xfs_inode_alloc()
> > >    call security_inode_free_rcu() before freeing the inode.
> > >  - Let pipe free inode from a RCU callback.
> > >  - Let btrfs-test free inode from a RCU callback.
> >
> > If I recall correctly, historically the vfs devs have pushed back on
> > filesystem specific changes such as this, requiring LSM hooks to
> > operate at the VFS layer unless there was absolutely no other choice.
> >
> > From a LSM perspective I'm also a little concerned that this approach
> > is too reliant on individual filesystems doing the right thing with
> > respect to LSM hooks which I worry will result in some ugly bugs in
> > the future.
>
> Totally agree with the concerns. However, given the savings is quite
> significant (saving two pointers per inode), I think the it may justify
> the extra effort to maintain the logic. Note that, some LSMs are
> enabled in most systems and cannot be easily disabled, so I am
> assuming most systems will see the savings.

I suggest trying to find a solution that is not as fragile in the face
of cross subsystem changes and ideally also limits the number of times
the LSM calls must be made in individual filesystems.

-- 
paul-moore.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ