Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6136393rdb; Thu, 14 Dec 2023 09:11:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0OxHkG3i7QBtZbkOrvRn+ul7zxtSKouP98xx2wr2zTNGkB5D9y/QG9X+My7KSUjIKVI6a X-Received: by 2002:a17:902:e885:b0:1ca:7f91:aa5d with SMTP id w5-20020a170902e88500b001ca7f91aa5dmr11680603plg.16.1702573862587; Thu, 14 Dec 2023 09:11:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702573862; cv=none; d=google.com; s=arc-20160816; b=LhoKsU9f4jT/AoEu8hGdZhRGXdLgzb/mtpKZkTxDdB6n2cMy8g3xo8SKAzJrN8+nPP WWigcZbamy5pAQbp07Z3rOyXdYtBa8YFS44LhnlaTXa3dIF+ISkAI/175w9YvUUprzyd u8D524MtvqQiQEdbCggQDs4gzqCggpPmUUuV4bqT0Sb0Go0R56Dtz39Kfd/DwNZqzzbj z/MKBfMZVtWbtYKnAg3XvaE6miI5xpQSHqwQBtWNHPFSC2pNmYRDSe4Se49mFChjAQHA UrnQBhb4A9N1LHN071aJtUmHFxMkmjBAwoLrRfDNoEpu2JKX1axwlryqILcPHDQwP//o VKBg== 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=vnTOGMdwPFTtLaj9f6gw88MiABGoNdYBba9e6QXQ9Io=; fh=e4uGr9b4mUXyBbS3/T8oKWuNGdTPau3Pm4RSvXRKvaA=; b=evHdjPYCkq6O9NUOrk5m8WaVJ/5yYAJc0rcz0+Tye6jAZcgnjNAdXADarSFngSpFhR 4mBb27xXT7eU0upX0cHb0fYfbIXaUuuSpWUjVCHkz1VUsa1mlUignVV7pqElcdSCg9qD +crv6MTLG2hyuW2dQF2LV/2yQc++5s4iYOUaTwazXfsf5uEEjJv/+q74VPqDpvc/+3ux xdO1v7XjYWn2BJ0MS5BmEI7+O8/+N0L942ZbMGU5w1Tp3asKiSYOX02/Ls7MhDrtB7bN XDe9sReeEAo1bj8QD8sdyDDFUCLiz/OcmkV9iQmLvzGL9fxd0AUsRPDykGaX9DOYOdZd iUuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs+bounces-591-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-591-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 v67-20020a632f46000000b005893a7c438esi11853006pgv.689.2023.12.14.09.11.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 09:11:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-591-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; spf=pass (google.com: domain of linux-nfs+bounces-591-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-591-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 4166C28269F for ; Thu, 14 Dec 2023 17:11:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74BDC63DF4; Thu, 14 Dec 2023 17:10:57 +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 9E006128; Thu, 14 Dec 2023 09:10:53 -0800 (PST) Received: from mail.maildlp.com (unknown [172.18.186.51]) by frasgout12.his.huawei.com (SkyGuard) with ESMTP id 4Srdhq23qHz9v7c2; Fri, 15 Dec 2023 00:53:31 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.47]) by mail.maildlp.com (Postfix) with ESMTP id 13A1F14065B; Fri, 15 Dec 2023 01:10:44 +0800 (CST) Received: from huaweicloud.com (unknown [10.204.63.22]) by APP1 (Coremail) with SMTP id LxC2BwBXlHSpNntl4xuLAg--.58219S9; Thu, 14 Dec 2023 18:10:43 +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 07/24] evm: Align evm_inode_setxattr() definition with LSM infrastructure Date: Thu, 14 Dec 2023 18:08:17 +0100 Message-Id: <20231214170834.3324559-8-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: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:LxC2B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W8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x07UZo7tUUUUU= X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAQALBF1jj5entgAEs9 From: Roberto Sassu Change evm_inode_setxattr() definition, so that it can be registered as implementation of the inode_setxattr hook. Signed-off-by: Roberto Sassu Reviewed-by: Stefan Berger Reviewed-by: Mimi Zohar Reviewed-by: Casey Schaufler --- include/linux/evm.h | 4 ++-- security/integrity/evm/evm_main.c | 3 ++- security/security.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/linux/evm.h b/include/linux/evm.h index cf976d8dbd7a..7c6a74dbc093 100644 --- a/include/linux/evm.h +++ b/include/linux/evm.h @@ -27,7 +27,7 @@ extern void evm_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry, int ia_valid); extern int evm_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry, const char *name, - const void *value, size_t size); + const void *value, size_t size, int flags); extern void evm_inode_post_setxattr(struct dentry *dentry, const char *xattr_name, const void *xattr_value, @@ -106,7 +106,7 @@ static inline void evm_inode_post_setattr(struct mnt_idmap *idmap, static inline int evm_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry, const char *name, - const void *value, size_t size) + const void *value, size_t size, int flags) { return 0; } diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index d452d469c503..7fc083d53fdf 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c @@ -558,6 +558,7 @@ static int evm_protect_xattr(struct mnt_idmap *idmap, * @xattr_name: pointer to the affected extended attribute name * @xattr_value: pointer to the new extended attribute value * @xattr_value_len: pointer to the new extended attribute value length + * @flags: flags to pass into filesystem operations * * Before allowing the 'security.evm' protected xattr to be updated, * verify the existing value is valid. As only the kernel should have @@ -567,7 +568,7 @@ static int evm_protect_xattr(struct mnt_idmap *idmap, */ int evm_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry, const char *xattr_name, const void *xattr_value, - size_t xattr_value_len) + size_t xattr_value_len, int flags) { const struct evm_ima_xattr_data *xattr_data = xattr_value; diff --git a/security/security.c b/security/security.c index 358ec01a5492..ae3625198c9f 100644 --- a/security/security.c +++ b/security/security.c @@ -2272,7 +2272,7 @@ int security_inode_setxattr(struct mnt_idmap *idmap, ret = ima_inode_setxattr(idmap, dentry, name, value, size, flags); if (ret) return ret; - return evm_inode_setxattr(idmap, dentry, name, value, size); + return evm_inode_setxattr(idmap, dentry, name, value, size, flags); } /** -- 2.34.1