Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp365717rdb; Thu, 15 Feb 2024 02:35:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXruqkpx9iCa6TbbCGTppQr4zNmyk/1Mm/cHjv5r7YXIYzEzS8Slr2/OhHn5GhykYtO0se3pZ29F5bzDvfKIoZG3shiG2qrrxI4+p4ruA== X-Google-Smtp-Source: AGHT+IESGOWAFMf/RPYK+1NUmDOhWNYR7nQQU9+XYJuqscN58G/wFm/6DykBK2K7ZNdsqYxMinc7 X-Received: by 2002:a05:6871:4508:b0:21a:478b:6a8a with SMTP id nj8-20020a056871450800b0021a478b6a8amr1290417oab.33.1707993321968; Thu, 15 Feb 2024 02:35:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707993321; cv=pass; d=google.com; s=arc-20160816; b=FhDs7wWYQo9QAwCQDA9DWLc0090ox7n6Nr6vkfmUwH/F0b2qJt97tE3gWy1ZcUHL6t aKIECw+k0DH5rTbrXi1S+P1nme5/SqnYLxxseCzYFVay66KcvK9dQPr+ruzjVPXFO3OT 2Rxc4XknB4KWuFIo/MGXnvtuWxFIGpHaNZ1R/XxOnh6gGL+/hn0lEcx5bG5rzkKxpk2P teThCol7402zk6WTRaewr0At+tv73myxlEuj3u6Gcky6aqjHN72+pRaoP4KtDY3TH+a2 eLVE6a1UUDt17Kbr7VfOIzOzGwVVWnE333bSvGKSYjffAgJagXEKbd7cJC4D21cZGz5W Qe1A== ARC-Message-Signature: i=2; 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=oI/WbWJS9BxuKEWGGac7xoR5wJ+8XGtI0fykXvFQFLg=; fh=C7VaS7fJHJaXY9o4fxqaroT+WFK+RA+7oLyqXjEJXBc=; b=VAWskaXTHnWD/xV1ozdQKcz1jF/xqMJ1WqiKLWF15CEo/UAVFtEU0zLo0rCqCON2gp 7rOfTXR7nBjZlom4xNElnt4mfIU57LNxTUVu+fhR254xN4P1ACggl5Rs7w19UWuQFzBR 03DU/kM7EfcfwN4J/9y7VOWOK8FvJAbGKfydKs3CZtV6vb28ERQzvR8KDvie5sHefTW+ HI44J4sOmKHjyZ5z9dKPSVNPFvTg9GDU89gyK6mDXCwcg7bBGHMB7A9MbF+o0/qwy+wd cyIx7dCuEwzCq8trm+7KLHmfPpeSwRFZJyQEml1MXdP8+FHFDwpPYrkp7M6TOZu6Kv5X W/Fg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-66632-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66632-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s27-20020a63525b000000b005dc5061bd7fsi870781pgl.557.2024.02.15.02.35.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 02:35:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66632-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-66632-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66632-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 836A728C1E1 for ; Thu, 15 Feb 2024 10:32:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 81EB6128800; Thu, 15 Feb 2024 10:32:13 +0000 (UTC) Received: from frasgout12.his.huawei.com (frasgout12.his.huawei.com [14.137.139.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22CA7126F07; Thu, 15 Feb 2024 10:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=14.137.139.154 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707993132; cv=none; b=aXfN77u53VvRsceSfzVxy1vYTK23Y8A5kwhl0z5OtpgIad0w4qKiDtUGB+lvvA+jkCwlg1RQrZYnMj1d1t2gblz4OaTP9uy6zojLv4QpQWym7+VOydmx0K1Kq0p+vmq1fWMNk9CXsuLdrtJwDK+xCEkls4kUMBgdIa/ev4gGU2I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707993132; c=relaxed/simple; bh=rKbM8A7s3icXmSAnkIY+SmGVA3ijDatDrRUHfMbCxtU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K+FqR7xQxuGSoxAJnF6wk2FdGh2LGpVyGqw5H1Jnj0hHE1AOgb3ZkymhmTNIqwDLDf+TlHPCfjROsX+JSxcYEi5LK0GyGqAMuAoGpu2TqR7IeNDuMd9c3KdnK34eR9Bh9yTSc59yUDRn2UY8eW7sA0HFquNePlf0Rc7a56nxamo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=14.137.139.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.18.186.51]) by frasgout12.his.huawei.com (SkyGuard) with ESMTP id 4Tb9qZ2nS3z9xrMj; Thu, 15 Feb 2024 18:12:58 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.27]) by mail.maildlp.com (Postfix) with ESMTP id D9C6C1408CE; Thu, 15 Feb 2024 18:32:01 +0800 (CST) Received: from huaweicloud.com (unknown [10.204.63.22]) by APP2 (Coremail) with SMTP id GxC2BwAXUCQD6M1lUHGHAg--.4426S3; Thu, 15 Feb 2024 11:32:01 +0100 (CET) From: Roberto Sassu To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, 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, eric.snowberg@oracle.com, dhowells@redhat.com, jarkko@kernel.org, stephen.smalley.work@gmail.com, omosnace@redhat.com, casey@schaufler-ca.com, shuah@kernel.org, mic@digikod.net Cc: linux-kernel@vger.kernel.org, linux-fsdevel@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 v10 01/25] ima: Align ima_inode_post_setattr() definition with LSM infrastructure Date: Thu, 15 Feb 2024 11:30:49 +0100 Message-Id: <20240215103113.2369171-2-roberto.sassu@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215103113.2369171-1-roberto.sassu@huaweicloud.com> References: <20240215103113.2369171-1-roberto.sassu@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Enc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UJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7IU1cdbUUUUUU== X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAQAOBF1jj5pfVQAAsq 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 Reviewed-by: Paul Moore Acked-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 5a13f0c8495f..b53ae408ad4f 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