Re: [PATCH 15/28] security: Introduce inode_post_removexattr hook
From: Christian Brauner
Date: Wed Aug 30 2023 - 14:53:07 EST
On Wed, Aug 30, 2023 at 11:31:35AM +0200, Roberto Sassu wrote:
> On Wed, 2023-03-08 at 10:43 -0500, Mimi Zohar wrote:
> > Hi Roberto,
> >
> > On Fri, 2023-03-03 at 19:18 +0100, Roberto Sassu wrote:
> > > From: Roberto Sassu <roberto.sassu@xxxxxxxxxx>
> > >
> > > In preparation for moving IMA and EVM to the LSM infrastructure, introduce
> > > the inode_post_removexattr hook.
> > >
> > > Signed-off-by: Roberto Sassu <roberto.sassu@xxxxxxxxxx>
> > > ---
> > > fs/xattr.c | 1 +
> > > include/linux/lsm_hook_defs.h | 2 ++
> > > include/linux/security.h | 5 +++++
> > > security/security.c | 14 ++++++++++++++
> > > 4 files changed, 22 insertions(+)
> > >
> > > diff --git a/fs/xattr.c b/fs/xattr.c
> > > index 14a7eb3c8fa..10c959d9fc6 100644
> > > --- a/fs/xattr.c
> > > +++ b/fs/xattr.c
> > > @@ -534,6 +534,7 @@ __vfs_removexattr_locked(struct mnt_idmap *idmap,
> > >
> > > if (!error) {
> > > fsnotify_xattr(dentry);
> > > + security_inode_post_removexattr(dentry, name);
> > > evm_inode_post_removexattr(dentry, name);
> > > }
> >
> > Nothing wrong with this, but other places in this function test "if
> > (error) goto ...". Perhaps it is time to clean this up.
> >
> > >
> > > diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
> > > index eedefbcdde3..2ae5224d967 100644
> > > --- a/include/linux/lsm_hook_defs.h
> > > +++ b/include/linux/lsm_hook_defs.h
> > > @@ -147,6 +147,8 @@ LSM_HOOK(int, 0, inode_getxattr, struct dentry *dentry, const char *name)
> > > LSM_HOOK(int, 0, inode_listxattr, struct dentry *dentry)
> > > LSM_HOOK(int, 0, inode_removexattr, struct mnt_idmap *idmap,
> > > struct dentry *dentry, const char *name)
> > > +LSM_HOOK(void, LSM_RET_VOID, inode_post_removexattr, struct dentry *dentry,
> > > + const char *name)
> >
> > @Christian should the security_inode_removexattr() and
> > security_inode_post_removexattr() arguments be the same?
>
> Probably this got lost.
>
> Christian, should security_inode_post_removexattr() have the idmap
> parameter as well?
Only if you call anything from any implementers of the hook that needs
access to the idmap.