From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCAFCC6FA8F for ; Wed, 30 Aug 2023 18:48:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242732AbjH3SrD (ORCPT ); Wed, 30 Aug 2023 14:47:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242862AbjH3Jxn (ORCPT ); Wed, 30 Aug 2023 05:53:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F276D1B0; Wed, 30 Aug 2023 02:53:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 801C260F0C; Wed, 30 Aug 2023 09:53:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B009C433C8; Wed, 30 Aug 2023 09:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693389219; bh=nknoL9w3Y4YI7sgEzXEgy31hHjSBtW5t6+EKdvixVT4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PGeSqtlADXPNsSRMnED5y2bc51bStrsRKgRLsG0vFmeuS7ZjsjtBx9snAHe0G8Vr2 puIswmGZMwYKKpvbAUG4hgCkBPfAo5LnG+Zqi6zCKquDATicIUaBHr5eqdyzNoLlT+ eDLqK7F5l64Ce6vhg3+b1Cyvv77qi6SuOOpM4UfSj8i00ym6zp0iNwdRQNPeW8AsCh s7jTGiZrttnG7dc7MMCLuv2nzzC2OWwW1dpk2JWvAsdtCdcLabRj31KBbnR0Ga2XvP vjAjcw2evRgbmv/HS/X8EAdywyIIJ9VzMleY3re1+0iiynu1XGC3tw9hN+y2/tEsbr Pj2cy6RWLJA5g== Date: Wed, 30 Aug 2023 11:53:32 +0200 From: Christian Brauner To: Roberto Sassu Cc: Mimi Zohar , viro@zeniv.linux.org.uk, chuck.lever@oracle.com, jlayton@kernel.org, dmitry.kasatkin@gmail.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, dhowells@redhat.com, jarkko@kernel.org, stephen.smalley.work@gmail.com, eparis@parisplace.org, casey@schaufler-ca.com, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, selinux@vger.kernel.org, linux-kernel@vger.kernel.org, stefanb@linux.ibm.com, Roberto Sassu Subject: Re: [PATCH 15/28] security: Introduce inode_post_removexattr hook Message-ID: <20230830-kultfigur-verrohen-a689c59911d6@brauner> References: <20230303181842.1087717-1-roberto.sassu@huaweicloud.com> <20230303181842.1087717-16-roberto.sassu@huaweicloud.com> <9d482f25475a9d9bc0c93a8cbaf8bd4bb67d2cd6.camel@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <9d482f25475a9d9bc0c93a8cbaf8bd4bb67d2cd6.camel@huaweicloud.com> Precedence: bulk List-ID: X-Mailing-List: keyrings@vger.kernel.org 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 > > > > > > In preparation for moving IMA and EVM to the LSM infrastructure, introduce > > > the inode_post_removexattr hook. > > > > > > Signed-off-by: Roberto Sassu > > > --- > > > 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.