Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6135148rdb; Thu, 14 Dec 2023 09:09:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4LO5SLTJj3PrSyTvQCTg4WQyG/h+LfTWWQpMV7b7bzrDKnGd7o00ksSMOPJnlE4t+6R0l X-Received: by 2002:a17:906:51ca:b0:a19:a1ba:da37 with SMTP id v10-20020a17090651ca00b00a19a1bada37mr4209892ejk.94.1702573783489; Thu, 14 Dec 2023 09:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702573783; cv=none; d=google.com; s=arc-20160816; b=hkaCDBXstQqsI7VwCbf+FbRGtftDMZHrE7vpcCuEWxY8YlqylYlIczpWrtakozxCnW Lz1OmySUnHIW0e4+vxWbWKu7U8CL1l5iyrwMQv1DUSkfH3E8+A/gAiW/+pCxJgW030/i 2g+I4NtcRjErdeC0ORuDErSQiM5j6gKc4XJEehINgp6rQiBzClsjvNN7ABvtzq+ZH68f 5KfNnVJJifIhrPsFC1IrPKlhjX5H4uN2TiPwd5G97nVeBQpPGxrz4ifJLDdlJ/3k0SLB DmQFhHJVkR8t6PuWVlbXXIph8FjkM0JSSNp7kW5mTfMTTGFwlVmM0fnceejqRwYeYZu1 nD2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=MdOZIOVJ5UNuDFmXOKc66YMEp6t+KPGzlbSFiZV/zyE=; fh=e4uGr9b4mUXyBbS3/T8oKWuNGdTPau3Pm4RSvXRKvaA=; b=Ry/3aQqejrgXy/ClEC9zCMtXaWX9pSRQzxYMGso4gpAovJgoiOII/V+UYX47J6mpAB 3O9yH5mERGjVUGwxKxzE6XMoG1eFL1qB/pM2BEDPoPTsnLwWx9DOwLrSaWN4P+cZaSvX JfVP7BcWPp7DVJ9NUJnykpjPMPVXx/tLWj9sBG5L0hM4OPJ/P2eE1Es4AMQuZcSGcYZq miHu7iLJmSiIWIxSrujH07gdhQy79Vflim3KL6DugDxZDsoUdccrMiQ+ffFC60tLKrtl DIAfc3KMli9Io/FSoZYCxtvz6a0ZdVKz8s3kUovYqtACW8yM8VxqUTpClLMTYHTAz+4R yCWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs+bounces-585-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-585-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y14-20020a17090668ce00b00a22fd9ce31fsi1664777ejr.489.2023.12.14.09.09.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 09:09:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-585-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs+bounces-585-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-585-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 35FB51F21E67 for ; Thu, 14 Dec 2023 17:09:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FA5463DE5; Thu, 14 Dec 2023 17:09:41 +0000 (UTC) X-Original-To: linux-nfs@vger.kernel.org Received: from frasgout12.his.huawei.com (frasgout12.his.huawei.com [14.137.139.154]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2A33118; Thu, 14 Dec 2023 09:09:36 -0800 (PST) Received: from mail.maildlp.com (unknown [172.18.186.29]) by frasgout12.his.huawei.com (SkyGuard) with ESMTP id 4SrdgL4knJz9xvP6; Fri, 15 Dec 2023 00:52:14 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.47]) by mail.maildlp.com (Postfix) with ESMTP id B741E1407FC; Fri, 15 Dec 2023 01:09:25 +0800 (CST) Received: from huaweicloud.com (unknown [10.204.63.22]) by APP1 (Coremail) with SMTP id LxC2BwBXlHSpNntl4xuLAg--.58219S3; Thu, 14 Dec 2023 18:09:25 +0100 (CET) From: Roberto Sassu To: viro@zeniv.linux.org.uk, brauner@kernel.org, chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, kolga@netapp.com, Dai.Ngo@oracle.com, tom@talpey.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, dhowells@redhat.com, jarkko@kernel.org, stephen.smalley.work@gmail.com, eparis@parisplace.org, casey@schaufler-ca.com, shuah@kernel.org, mic@digikod.net Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, selinux@vger.kernel.org, linux-kselftest@vger.kernel.org, Roberto Sassu , Stefan Berger Subject: [PATCH v8 01/24] ima: Align ima_inode_post_setattr() definition with LSM infrastructure Date: Thu, 14 Dec 2023 18:08:11 +0100 Message-Id: <20231214170834.3324559-2-roberto.sassu@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231214170834.3324559-1-roberto.sassu@huaweicloud.com> References: <20231214170834.3324559-1-roberto.sassu@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: M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AIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU1cdbUUUUUU== X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAQALBF1jj5ensAAAs- From: Roberto Sassu Change ima_inode_post_setattr() definition, so that it can be registered as implementation of the inode_post_setattr hook (to be introduced). Signed-off-by: Roberto Sassu Reviewed-by: Stefan Berger Reviewed-by: Casey Schaufler Reviewed-by: Mimi Zohar --- fs/attr.c | 2 +- include/linux/ima.h | 4 ++-- security/integrity/ima/ima_appraise.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/attr.c b/fs/attr.c index bdf5deb06ea9..9bddc0a6352c 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -502,7 +502,7 @@ int notify_change(struct mnt_idmap *idmap, struct dentry *dentry, if (!error) { fsnotify_change(dentry, ia_valid); - ima_inode_post_setattr(idmap, dentry); + ima_inode_post_setattr(idmap, dentry, ia_valid); evm_inode_post_setattr(dentry, ia_valid); } diff --git a/include/linux/ima.h b/include/linux/ima.h index 86b57757c7b1..910a2f11a906 100644 --- a/include/linux/ima.h +++ b/include/linux/ima.h @@ -186,7 +186,7 @@ static inline void ima_post_key_create_or_update(struct key *keyring, #ifdef CONFIG_IMA_APPRAISE extern bool is_ima_appraise_enabled(void); extern void ima_inode_post_setattr(struct mnt_idmap *idmap, - struct dentry *dentry); + struct dentry *dentry, int ia_valid); extern int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name, const void *xattr_value, size_t xattr_value_len); extern int ima_inode_set_acl(struct mnt_idmap *idmap, @@ -206,7 +206,7 @@ static inline bool is_ima_appraise_enabled(void) } static inline void ima_inode_post_setattr(struct mnt_idmap *idmap, - struct dentry *dentry) + struct dentry *dentry, int ia_valid) { return; } diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c index 870dde67707b..36c2938a5c69 100644 --- a/security/integrity/ima/ima_appraise.c +++ b/security/integrity/ima/ima_appraise.c @@ -629,6 +629,7 @@ void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file) * ima_inode_post_setattr - reflect file metadata changes * @idmap: idmap of the mount the inode was found from * @dentry: pointer to the affected dentry + * @ia_valid: for the UID and GID status * * Changes to a dentry's metadata might result in needing to appraise. * @@ -636,7 +637,7 @@ void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file) * to lock the inode's i_mutex. */ void ima_inode_post_setattr(struct mnt_idmap *idmap, - struct dentry *dentry) + struct dentry *dentry, int ia_valid) { struct inode *inode = d_backing_inode(dentry); struct integrity_iint_cache *iint; -- 2.34.1