Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp38279rdb; Wed, 21 Feb 2024 16:19:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVR0eRY7TjEgKkyerETmampj/DAMyCg9tjD2vOLJsUUtqDeApT8r7BUhMO2dRgeE4Kp7n6hm23MUr1Vo0nxztx8kZvSFo6wWlIlC9OlMA== X-Google-Smtp-Source: AGHT+IEcTHybkncKwdQfAxvxASwqu3G85ngGjVGiEimcrGySpwAWvKXbKCd6QlYt1+QXWakb+eXd X-Received: by 2002:a05:6358:7f96:b0:17a:ec6c:4236 with SMTP id c22-20020a0563587f9600b0017aec6c4236mr23391417rwo.2.1708561177799; Wed, 21 Feb 2024 16:19:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708561177; cv=pass; d=google.com; s=arc-20160816; b=ealbjB59vJnAeNV/Kfr/jz7GOhndKlMzoEXnEY2SvfeH9ZAhOPV8bv0aca18e9Mlu4 XJHPXbz7oCXHfAdP8efcdRzA/MihXz/jLeHkngMz6L7lXaWvxi2shXlsvA0FhP8v6zgD JOz/HRZbqaptLwr0wP9OaPv7tlKz3Z/jJwfyzFxNwGHCu0To1G0WfMuYRWiLFAXqbMmW zIPRRo2kPmVjmrcjjbYDcJH3SjPZp1xFUjtVMB1th7FVjy4pmptCcIz1ni6ILqH9mzN0 UKzXLhRomXapABC7Qfwpf/UuxLrubS0t2bKRkyoY0dzEApoKjfqpgHayIGGfCNIJuVyE HBVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=J7oaGryxbVrUL2E+pOOS5V370VmMkOZfbF1VgDo0Va8=; fh=45kOLLcrAgtrL5vPwuQXLwAe1nevLCJOofOPhdqcsdI=; b=ukIKT+2HtutWXeH1mzoDr5ppVRUUcue3SZkwKei96rdNI2xaRkvXNvieC5hamitBnw RtGarMofGxp4NFOK5nsBTYhpl5YKrjlklQPrvDaXMx8oXC1uO1P1c2QM8XgsIE4wRNq4 Zhn+9CRmciIN97R37iEwhlyAexKM8ZeBjJBHS49ExLgPmwglk55LGvGkau4jXIHaCzJ7 xLstWb6a+wB8TdWFc+IeUcx0TqkA5lL7pHkomiqCggzqHL/Ur3vJ3Qb/fX9ASaqEba9n ZyLeYt3cetFcoKcuAy25gPZslps45wPJ6uws2NwbjVPKQGNZiOQcpxLVxqnNuJo+CCf0 RD5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=MHY5O+XQ; arc=pass (i=1 spf=pass spfdomain=paul-moore.com dkim=pass dkdomain=paul-moore.com dmarc=pass fromdomain=paul-moore.com); spf=pass (google.com: domain of linux-kernel+bounces-75715-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75715-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u21-20020a63b555000000b005b91536981csi9185649pgo.11.2024.02.21.16.19.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 16:19:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75715-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; dkim=pass header.i=@paul-moore.com header.s=google header.b=MHY5O+XQ; arc=pass (i=1 spf=pass spfdomain=paul-moore.com dkim=pass dkdomain=paul-moore.com dmarc=pass fromdomain=paul-moore.com); spf=pass (google.com: domain of linux-kernel+bounces-75715-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75715-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com 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 71CAE284F18 for ; Thu, 22 Feb 2024 00:19:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52A9EF501; Thu, 22 Feb 2024 00:19:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="MHY5O+XQ" Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B6008C0B for ; Thu, 22 Feb 2024 00:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708561162; cv=none; b=Thj4p5R1MwcKRkicif6LqJQ3yk/8FObvIOLcSeiUIqlRjcwCt1RpB37F5SCqxXPRl87cyFa/MCn8JqWF9fP5HPCvznSuBiqdNfl5w7ZkJPTvppW4ImOIPSOyS7zofooaKEnX/wCgjKilabHU8hzHd7uXs81FupJUhmUU9N9EVik= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708561162; c=relaxed/simple; bh=YI3P7HeQYLh9u7/Ubmalb2dwpwldBv2QjTTYBegsd9Q=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=b1gdDmSR9LpkC1G8t/94ELXRiioRYRWov6KMv/UuGnxnW248Jn3ISzPb+lL1J+zVVva1uIuddCc0XpVKzwM4ruR59nXLVl6TL6k7eX3dS5Dy0kBcAMbBJC+24fo0IPvUwlwA3T5MfGzU7Mg0Ppv9bfY/bNlhCpuYhEOjAGbMc7c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=MHY5O+XQ; arc=none smtp.client-ip=209.85.219.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-dcbc00f6c04so5947684276.3 for ; Wed, 21 Feb 2024 16:19:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708561158; x=1709165958; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=J7oaGryxbVrUL2E+pOOS5V370VmMkOZfbF1VgDo0Va8=; b=MHY5O+XQpYqBFmZskum/pRe153fd0o4QAVq/T21KW9KNGfS+LP7cxNUe0hRvKZwhJj fN4MXtfNfczIcAFGWl686biDxSpZ/bOJYQ2u43UC7FqWgi2DXz9M7y2OSjbKZEtjjrxP sjiZvMg4iH5UYkqz2iMtSaJ5URne0cFb0f3NUJ2PFoVnDVDxO7e5TymJtqQwIgNwmVFl N+55ebpHYQwUzYmZ6bj6udOdtiUFCz5M2NSR7NyW6IYuZwdyL2oMBQHXgyyKiCmc+0FC 5IUS2arojCcGGF64/Vtx08f1dZTEfXwiZ5GoKqSqqq0AvSG3SjW9SYumzHJL6Hr5zzsP o8Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708561158; x=1709165958; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J7oaGryxbVrUL2E+pOOS5V370VmMkOZfbF1VgDo0Va8=; b=n/icKfGR2Q7CScQ48QYeHDuQNFAYdiUla1tKGz/ccdO+1z3LgClQHQEFvOOn9eyco3 aFb+gVbI/b6jsoUPesU6L6jnXMPP8fwWizlQAFHmIU+5CYfG9CRAUxHFj+dxOP2KWlsE bGxn/Dr4p/Wms2ZaayiMc9KZcUJ7l435y4Mg6igQD3XhLeeM3wIxFShjlki4KXr2Ix28 5l6uf7zpz/sMjxOyaMlrfSevJEcmcxxVGuqiN1h78alNjmxKGkdxSYH4jl8LAt6L6lXN H7oWZAHSTvOLwEH9cMFs2jK6ACTxqZU4AH9+J6MYQJc7iWQrG72COG7MfOZjMEaJH6WX vo4g== X-Forwarded-Encrypted: i=1; AJvYcCVKZ+7xuX7po4RI7N4MIjkhWkqrPzZvJU8yH4tju2gFyhigUR+jlDrPE1IeKKb/Rxm5KWma8ZHfwkhBdWCI+HHb3lhVa7iNHEI87ERO X-Gm-Message-State: AOJu0Yy+2CJLdXHnxAUcVIhDQZ6yBHGJdwzI+RH3Dp6yW6Xm7nugSj9O /3NWglDiynsDthM6RSzh1tM8QvcgVE30tFGYtjfUlqCmWd35ZHi77jCKkC/HN4CJzdANIlU9gyu jTvxmp1c7PXKTisTNJkNfJfhbL2Xfq+pcF07G X-Received: by 2002:a25:2183:0:b0:dc2:2d0a:4d55 with SMTP id h125-20020a252183000000b00dc22d0a4d55mr711081ybh.63.1708561158458; Wed, 21 Feb 2024 16:19:18 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240221-idmap-fscap-refactor-v2-0-3039364623bd@kernel.org> <20240221-idmap-fscap-refactor-v2-12-3039364623bd@kernel.org> In-Reply-To: From: Paul Moore Date: Wed, 21 Feb 2024 19:19:07 -0500 Message-ID: Subject: Re: [PATCH v2 12/25] selinux: add hooks for fscaps operations To: "Seth Forshee (DigitalOcean)" 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 21, 2024 at 7:10=E2=80=AFPM Seth Forshee (DigitalOcean) wrote: > On Wed, Feb 21, 2024 at 06:38:33PM -0500, Paul Moore wrote: > > On Wed, Feb 21, 2024 at 4:25=E2=80=AFPM 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 mn= t_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. Fair enough, but I'd be a lot happier if you included the call in case something changes in the future. I worry that omitting the call would make it easier for us to forget about this if/when things change and suddenly we have a security issue. If you are morally opposed to that, at the very least put a comment in selinux_inode_set_fscaps() about this so we know who to yell at in the future ;) --=20 paul-moore.com