Re: [PATCH 5/9] LSM: Introduce inode_post_setattr hook

From: Christian Brauner
Date: Tue Oct 18 2022 - 10:50:31 EST


On Thu, Oct 13, 2022 at 03:36:50PM -0700, Kees Cook wrote:
> IMA and EVM need to hook after setattr finishes. Introduce this hook and
> move IMA and EVM's open-coded stacking to use it.
>
> Cc: Mimi Zohar <zohar@xxxxxxxxxxxxx>
> Cc: Dmitry Kasatkin <dmitry.kasatkin@xxxxxxxxx>
> Cc: Paul Moore <paul@xxxxxxxxxxxxxx>
> Cc: James Morris <jmorris@xxxxxxxxx>
> Cc: "Serge E. Hallyn" <serge@xxxxxxxxxx>
> Cc: Takashi Iwai <tiwai@xxxxxxx>
> Cc: Jonathan McDowell <noodles@xxxxxx>
> Cc: Casey Schaufler <casey@xxxxxxxxxxxxxxxx>
> Cc: linux-integrity@xxxxxxxxxxxxxxx
> Cc: linux-security-module@xxxxxxxxxxxxxxx
> Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
> ---
> fs/attr.c | 3 +--
> include/linux/evm.h | 6 ------
> include/linux/ima.h | 9 ---------
> include/linux/lsm_hook_defs.h | 3 +++
> security/integrity/evm/evm_main.c | 10 +++++++++-
> security/integrity/ima/ima.h | 2 ++
> security/integrity/ima/ima_appraise.c | 2 +-
> security/integrity/ima/ima_main.c | 1 +
> security/security.c | 8 ++++++++
> 9 files changed, 25 insertions(+), 19 deletions(-)
>
> diff --git a/fs/attr.c b/fs/attr.c
> index 1552a5f23d6b..e5731057426b 100644
> --- a/fs/attr.c
> +++ b/fs/attr.c
> @@ -423,8 +423,7 @@ int notify_change(struct user_namespace *mnt_userns, struct dentry *dentry,
>
> if (!error) {
> fsnotify_change(dentry, ia_valid);
> - ima_inode_post_setattr(mnt_userns, dentry);
> - evm_inode_post_setattr(dentry, ia_valid);
> + security_inode_post_setattr(mnt_userns, dentry, ia_valid);

I like that change. In general, no more separate evm_* and ima_*
invocations in the vfs would be much appreciated.