Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp34927rdb; Wed, 21 Feb 2024 16:11:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUERExVZn2imx1GQxxd0wXBIfo2g4nmjdEen0p/6/lkx0JVSxw6Fdgyg4jeHF2aAh0JdHG890nz7DecZI/4GbOfG2Q0w5I7osQJ+NBJMA== X-Google-Smtp-Source: AGHT+IH1MnlUuWLz5tR0H9oqZh7WuSzSgCiaUZ6ecImD9iFzi7PD5aJER6Vt1kOBUT+4w9uOABh7 X-Received: by 2002:a05:620a:90d:b0:787:28c3:aeb9 with SMTP id v13-20020a05620a090d00b0078728c3aeb9mr17690229qkv.8.1708560667982; Wed, 21 Feb 2024 16:11:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708560667; cv=pass; d=google.com; s=arc-20160816; b=iv+RAHEKVMTOFPms71yozxTiicLGRC5EDX9tw8buhwmB3nlRUHMH9BANYcDlQXNVK4 ysF52Jn+3wDVaT0PzpkDJPP018FkPwN2mEzXdpr9SpGRU3prQWmM14d4Lylt5DYwqGPh r/8kUc/FoNSh6GeZClkk7u0/s6oBqDyczgC+fMxvLc6UVuB1843aNmhHOxMWZTJZA1wR e0KtX+SOhHsS3QB/QdY4JdC5mUYIRfSRWiI2ZgRJeWiAgNQM2SIwSjiBik8YAKdYeRPv 6cxdmSoghQxuIq3BKzZpRMr3ewZPSqLfg3lBqm5IKl4lne8oa+1x6czEmCcuZBFngjnA wcSw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=a35S9GfVbq0ZzauiYd16QwbOrxXPX1BlR61fkwS5Tso=; fh=EzATVX8pnNokhAQWwBZNNKko/nTsiJ3PsvxHE99Bc8Q=; b=egyI3YG/vfAJdrAo8qPNZKd2lqCTwBWBV23BhCiETeFW9eErYK+QObp7rB4xsLK+Gt UoAJ5QSB6+WgvH9sT0G0pRZha00uPGYXaO1EaQZbUGLBWkfyaqnOmBZbWzyzYvKDfiOO /0hQGItaxny3804kBhsBMd8Y8oZl24T2ZdZZuh0Qbyx2Bffj93CYjbDmkpat/dOWw5Yw tE//c/DSmNkBIeGJjWfp1sJSoLNRsghu8Vd77XWT0b1Y0bY1CHJMoh18uSb6Qw8tg2Ph 1FNHDezsyyiDe77c0kUpyJp4f5pC6ODNEWzJSlYEjExnV0nkuATZK9SjWyfeJeT9P6Ei ByQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WI8G2UF6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-75704-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75704-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u8-20020a05620a084800b007872614fc53si11573362qku.667.2024.02.21.16.11.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 16:11:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75704-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WI8G2UF6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-75704-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75704-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B8ABF1C217F0 for ; Thu, 22 Feb 2024 00:11:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A567010A19; Thu, 22 Feb 2024 00:10:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WI8G2UF6" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AD32AA35; Thu, 22 Feb 2024 00:10:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708560645; cv=none; b=dmBpybcBKCis/BRpwNag/jTQvYtGY0efoZzWFWJsPEr2ge2b4DHAsZVdNqgEJ8h594mN/cSXu991xBZECHJHVNtdRX8hTYKQI2QxCpH8vouBOVEwH6qsM37UVBuOnNG3y3SIdjuuweWt8ige2lqXBULRqdGOIBroyE+QHCn6lRc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708560645; c=relaxed/simple; bh=zlJyY3XbdGnoeuA5i4CL3so5iDSHMzSmQnC6t4+gix4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bDy6UzwtpJdYRvf7+BnW6sq/fIAA/AVUr+1elUTcDXAQnRIzVrfaZ6Q7bOKY+Jz5xeP2Zi+zzDZNwCeqrXkuZcZcJBoPIiI6C8pNCGeUUJLweG+eQihcJ1hpExdXtapDXNsEyblEFNUSPgSA2r7VJPt3/DuSXUiVB1Dhsd3ZB10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WI8G2UF6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE6E7C433F1; Thu, 22 Feb 2024 00:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708560645; bh=zlJyY3XbdGnoeuA5i4CL3so5iDSHMzSmQnC6t4+gix4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WI8G2UF6Y+uwZhKf4ihUf9stmKvZ91fGSJZc3PPmCtCjLuaro9rQSKP7q4y6PP348 KDWPM0ohXL+7wtH8MTTfPhNWn1XrX3D1dtF8j9c8I4V/zPEX8Mscb0aEjY77J2dgJ5 PVQD+pzHEABosHTh5/jnrtZ6Rx+qLIhYZZ3sW8QgHo7vwwIqPve1UvdL3TMmFSY/Oo ej/2ix1Oe3qU7q/IKQFrElHCrpYPPdbgiGy3OLr8SmT95d5JbRH71anRrz5xpWCrrt llmyfqzOTXLVvLZMjkcnfEVCeoBNFIMElRmCHbsf5tKnyBHMYAh9XyINg49vfJT6cM lPV2HH7DkguaQ== Date: Wed, 21 Feb 2024 18:10:44 -0600 From: "Seth Forshee (DigitalOcean)" To: Paul Moore Cc: Christian Brauner , Serge Hallyn , Eric Paris , James Morris , Alexander Viro , Jan Kara , Stephen Smalley , Ondrej Mosnacek , Casey Schaufler , Mimi Zohar , Roberto Sassu , Dmitry Kasatkin , Eric Snowberg , "Matthew Wilcox (Oracle)" , Jonathan Corbet , Miklos Szeredi , Amir Goldstein , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, audit@vger.kernel.org, selinux@vger.kernel.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, linux-unionfs@vger.kernel.org Subject: Re: [PATCH v2 12/25] selinux: add hooks for fscaps operations Message-ID: References: <20240221-idmap-fscap-refactor-v2-0-3039364623bd@kernel.org> <20240221-idmap-fscap-refactor-v2-12-3039364623bd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Feb 21, 2024 at 06:38:33PM -0500, Paul Moore wrote: > On Wed, Feb 21, 2024 at 4:25 PM Seth Forshee (DigitalOcean) > wrote: > > > > Add hooks for set/get/remove fscaps operations which perform the same > > checks as the xattr hooks would have done for XATTR_NAME_CAPS. > > > > Signed-off-by: Seth Forshee (DigitalOcean) > > --- > > security/selinux/hooks.c | 26 ++++++++++++++++++++++++++ > > 1 file changed, 26 insertions(+) > > > > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > > index a6bf90ace84c..da129a387b34 100644 > > --- a/security/selinux/hooks.c > > +++ b/security/selinux/hooks.c > > @@ -3367,6 +3367,29 @@ static int selinux_inode_removexattr(struct mnt_idmap *idmap, > > return -EACCES; > > } > > > > +static int selinux_inode_set_fscaps(struct mnt_idmap *idmap, > > + struct dentry *dentry, > > + const struct vfs_caps *caps, int flags) > > +{ > > + return dentry_has_perm(current_cred(), dentry, FILE__SETATTR); > > +} > > The selinux_inode_setxattr() code also has a cap_inode_setxattr() > check which is missing here. Unless you are handling this somewhere > else, I would expect the function above to look similar to > selinux_inode_remove_fscaps(), but obviously tweaked for setting the > fscaps and not removing them. Right, but cap_inode_setxattr() doesn't do anything for fscaps, so I omitted the call. Unless you think the call should be included in case cap_inode_setxattr() changes in the future, which is a reasonable position. Thanks, Seth