Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp19729rdb; Wed, 21 Feb 2024 15:32:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX49+Hv+v9A0ZWdCgevACYY3EfCVn78McYlWR8M9MtqvLwLS97uMZuGINSBxZktLFYYA8FKAkzXTz1LMEoELsaWyHev5niQejISaBK1Lg== X-Google-Smtp-Source: AGHT+IE30gPFO58bowvQQH1p11Wcthe6raQw4njnkcVKMAhqWBGBX2WoSw7rhP4mGdsRBO9+FJya X-Received: by 2002:a05:620a:5d:b0:787:8dd3:60e with SMTP id t29-20020a05620a005d00b007878dd3060emr2647447qkt.30.1708558329538; Wed, 21 Feb 2024 15:32:09 -0800 (PST) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id dp13-20020a05620a2b4d00b007879e1243e0si96759qkb.734.2024.02.21.15.32.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:32:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@paul-moore.com header.s=google header.b=GwG5Xtha; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-75660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4F6411C229EA for ; Wed, 21 Feb 2024 23:32:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D3EEF126F11; Wed, 21 Feb 2024 23:31:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="GwG5Xtha" Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) (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 AE7B31292FC for ; Wed, 21 Feb 2024 23:31:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708558316; cv=none; b=N8TgNHNET2v3wAULzyQJzYY/WkaDArnB9Ghn7WJd/MaOaaVUm0vvb8KYdT93KfIA0EEN38l1jUpV1lcPpRtpmS1ayBdVDF6Ze8yHT0cJkkTxRwLm0I4m+neNE9LS+eN7AzKVMpzrl1CCUUlw8/FFtfn6vLqtlSRxvZ+9RS2RYiU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708558316; c=relaxed/simple; bh=WgLwLSocZ7FS/OEk2fPe2rx5sR/6WFIAnJST+HRVhCc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=cSRYfltP7cWJRKQ0PtQgv5NMXnfOPhTa0rxymSRjsWJ1GRyrpQuEraH1Zt/dwnvlRjea91AeQZhBnlaga6phZlvNS+BaV4qx3/reRpvqxUw5WbAUfT9SHIF1qpkZnhW7Ye/7m07/B5yQQDwopai9v2s879bHiBYnIm8n5Y7aEok= 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=GwG5Xtha; arc=none smtp.client-ip=209.85.219.173 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-f173.google.com with SMTP id 3f1490d57ef6-dc742543119so6066749276.0 for ; Wed, 21 Feb 2024 15:31:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1708558313; x=1709163113; 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=fZu2GPrrRR4joejlRHI45PmLXsG4a+4mbcvu2KMsfNQ=; b=GwG5Xtha5H1vqGrGKMhJTy7HsndGLVt/3YtlVxa9bl/MkQxHqP7KlJmCG2AfacfGNx 75ZCNWavwgS6x9vOLCE+TdATKrHN0FExiLxmZb0uBY2gfMtC+yCla+N9ez6TWjcTAyYJ M3+uRdoPqQuADsyoLrdxIibK91zUl+K40eL3mAUlkf40CFd0eTwpGTvKnk82MWfubbuP fFZVyBar9aJ+glrmmOb5y/g6TtnZcbrLj0Zv3c5QuTfJQqi34ovQwSOugA5MBXt2Zes2 JR1bqiSQC8toLOiFsOJT8P4vJMvObpe00mMlyO8FgSyb5Q7MxcwBI+91Qq3x3gcTx07f ypxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708558313; x=1709163113; 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=fZu2GPrrRR4joejlRHI45PmLXsG4a+4mbcvu2KMsfNQ=; b=PzZ7JQEtmnv1e6Yal+NC2GYrEGrHHMQd/mtkoGWfP9LGNRiMbpmmGHmzIB65Ks1hi7 +a/GtcYXvk8kz9ajxVFgwdELiN5QPb+d+hUa4nFLlqOFYuFbA+CoER7G/PPTmy1xb3Gb oxiGXYAyutehvMYcEboQ1+5iLoMFn0YQm09DRqNAfVMOT0vv890kgmHVaSreveYPhQeE x35L8AbWjaak2HZvbxrTkNyYu/ehBUqol1youR9BaXIAJY7hJ8W7TmRG9D5aLfC9GJ7T kSLf0sUbmZVzAuQsO8LqgRvB5x/Px43UGWS5k2X6rew8GC0X/qnTmpUCVPYvgkqTTuvl vv2A== X-Forwarded-Encrypted: i=1; AJvYcCUqeizIe9YXz/ZTiLx+2fcOldh1M030o4ss3qWyNSW27VAl2ENObOVSiiP54IBDG8sgVrtMAj06LJGz95C2Ze1LwhAJex6wbtEQ5icy X-Gm-Message-State: AOJu0YxaIzWH4rnRw49rR+07xH8pCkWqTchdxylgcefGuyCGAm8EFjls cN+AY9tWx/9qqQJt5qUbts77ta+vybUY5wE7BC5w1yRuPjYO930IBIyG9GKjX1/myRetH0AUMxk tOL8+wcdspB/1pyW8pKCqm9f9yFCXMQeskd8X X-Received: by 2002:a25:8881:0:b0:dcb:e82c:f7d with SMTP id d1-20020a258881000000b00dcbe82c0f7dmr840538ybl.41.1708558313639; Wed, 21 Feb 2024 15:31:53 -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-11-3039364623bd@kernel.org> In-Reply-To: <20240221-idmap-fscap-refactor-v2-11-3039364623bd@kernel.org> From: Paul Moore Date: Wed, 21 Feb 2024 18:31:42 -0500 Message-ID: Subject: Re: [PATCH v2 11/25] security: add hooks for set/get/remove of fscaps 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 4:26=E2=80=AFPM Seth Forshee (DigitalOcean) wrote: > > In preparation for moving fscaps out of the xattr code paths, add new > security hooks. These hooks are largely needed because common kernel > code will pass around struct vfs_caps pointers, which EVM will need to > convert to raw xattr data for verification and updates of its hashes. > > Signed-off-by: Seth Forshee (DigitalOcean) > --- > include/linux/lsm_hook_defs.h | 7 +++++ > include/linux/security.h | 33 +++++++++++++++++++++ > security/security.c | 69 +++++++++++++++++++++++++++++++++++++= ++++++ > 3 files changed, 109 insertions(+) One minor problem below, but assuming you fix that, this looks okay to me. Acked-by: Paul Moore > diff --git a/security/security.c b/security/security.c > index 3aaad75c9ce8..0d210da9862c 100644 > --- a/security/security.c > +++ b/security/security.c > @@ -2351,6 +2351,75 @@ int security_inode_remove_acl(struct mnt_idmap *id= map, .. > +/** > + * security_inode_get_fscaps() - Check if reading fscaps is allowed > + * @dentry: file You are missing an entry for the @idmap parameter. > + * Check permission before getting fscaps. > + * > + * Return: Returns 0 if permission is granted. > + */ > +int security_inode_get_fscaps(struct mnt_idmap *idmap, struct dentry *de= ntry) > +{ > + if (unlikely(IS_PRIVATE(d_backing_inode(dentry)))) > + return 0; > + return call_int_hook(inode_get_fscaps, 0, idmap, dentry); > +} --=20 paul-moore.com