Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1638142rda; Mon, 23 Oct 2023 20:54:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdl6gO09qN78Paj/mo73V3Hf0rdklMILrV+X1QrVyZBeBBaosTvuCUZlluQv8TFsbrh+CA X-Received: by 2002:aca:240a:0:b0:3ab:74a2:ab2b with SMTP id n10-20020aca240a000000b003ab74a2ab2bmr11670373oic.48.1698119678390; Mon, 23 Oct 2023 20:54:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698119678; cv=none; d=google.com; s=arc-20160816; b=Cg/gb3XSktLWwd840aBvme+r1Hxh90ZDHXUDAx7vUuj/wVFYzFC/GsRrd+0mS3E+5y Cj30XlC6blgQe1DR/tT7bxTtA+lQM89wsF1Szrn5fXDRrovzjwr1yMuxK83ajltMwPB3 bRla9Y3cS36noC1FOFIIphyYL4mrx/OxUJzhzzz3hMOjLQ6F07VLBzUVFNe0efOxAKZz GkvDnNqGd31k8lFdJRbhJhbsHfcUIhY9KHyAV5H1mrsaeNnSbu8v0BxMKM5d5XP/Kl1k HU/yTtEHBQzqs1cJmoU/8FvrT7Fc4Tfo+0w+rn7kyaQS6W4Ghgu0D+ObVmgycagRmdF6 RETw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:subject:cc:to:from :message-id:date:dkim-signature; bh=GnPZt7wTu5bHl+yZIdMyk9dSEtxPVy94lr+8pKkfEn4=; fh=fHHNkGg+NzKoJxHGMh0JSMLpg18Ht1OPApOBL8ui3GA=; b=G76GygfNKGFyhZtnOVGgIFtZ+GRR2MF/VovjkVGodNwmKuyizTkmjemOPJkzr3NYaS JnEle4wMfc17Pq8y6hey3lAHOdk8LtDWWvlTat1ulIIMTrff8cj1v8oxNft6URQdf7si 2gCWKimmfM7odk6NRbWI3VoxCadxY/ObTC4JAO6Jc8yIfbB7SrnFKmlndI2QTKaA/Oy1 ypxgyHsHyoaycuC+iENok8T1ua2g1PmJYGzAnSo6NDfJykMDUp5LI6lfWw0tGqX43H7/ bxNQ7PsHZctVMvxUwzqg/E03awiOHG7gUdcGIFm3y0wHM/CQMWwOcxRt4RjUJ3XZsIKb Kpag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=Qk2NAnk+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id o13-20020a170902d4cd00b001c38666f77dsi7824389plg.596.2023.10.23.20.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 20:54:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=Qk2NAnk+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3ADFC80A9AAD; Mon, 23 Oct 2023 20:54:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232177AbjJXDwv (ORCPT + 99 others); Mon, 23 Oct 2023 23:52:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232254AbjJXDwq (ORCPT ); Mon, 23 Oct 2023 23:52:46 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11C0D10D9 for ; Mon, 23 Oct 2023 20:52:27 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-77891c236fcso312570185a.3 for ; Mon, 23 Oct 2023 20:52:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1698119546; x=1698724346; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:message-id:date:from:to :cc:subject:date:message-id:reply-to; bh=GnPZt7wTu5bHl+yZIdMyk9dSEtxPVy94lr+8pKkfEn4=; b=Qk2NAnk+d3PS2nhphbsNh4pXDwIkiF/OEugwNqtX8DEU03CEfroRIc3UcQKLCx0RJB c/SnoKoKs7NXwkEjbsod/f2u8PP3uqJdYiRs/R2l+++7jXOlKo3J8QMLftlSgdlmrf+S WDpNm7dOHUoRzJI8nxhDZADh7OPpxVkCdKQNTLwgNHsnyxbj6+fDjztk56ap664Rh+ph GiJ4k5abmtn8z0O2bAg5QoevXeJcBa4b8IMwN9UzkCbNXv5BiYWoCajzAoBQt0a80b5Z nchL+39mHH0b1gi98t637zPu3o3WUyn7fI3B9Y99ScaMgRAxoK5C1XdyDLO4ci0w0AAU IysA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698119546; x=1698724346; h=in-reply-to:references:subject:cc:to:from:message-id:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GnPZt7wTu5bHl+yZIdMyk9dSEtxPVy94lr+8pKkfEn4=; b=KrRtIaaOvnFcbC1Uqx7R59g0ZzUxybFwbrhswJ3VxR50V+CqJxxj/MRbb5Mg0dXDXC sqcISqXOBeMCc94CYJuI0yyXdwqQEKVkWBimh3s2sa44msa/4knk7DTnS8qq+W/C66c/ ifL2NUICZhFXZ1oKqrmTOycPrJv3CEagYhrOo3DDT9Zkzb7jvV5i9DJrLNzrel6B8X7M uo6hLEALbwBL8xvnqymYmFUMmfyg/XW28EfIg1+3f0RhLSjb8fHGjqdZ16GsHIIxjDsV +LYH/hRsoG6Xih9q4HUR0Q1q51ArBTe0rzENYjVcEJ36HrCLdT3+sRHeD4ibYqe9jZxM AqCw== X-Gm-Message-State: AOJu0YySSmkre3UBM6LykZP8n1AUQMZ41asDJECLrdWirLC2gfyB/C+U mXaObxkoJIRFd0q3R2Of8NSA X-Received: by 2002:a05:620a:4049:b0:778:9232:a564 with SMTP id i9-20020a05620a404900b007789232a564mr13553158qko.47.1698119546060; Mon, 23 Oct 2023 20:52:26 -0700 (PDT) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id w12-20020ae9e50c000000b0077407e3d68asm3162408qkf.111.2023.10.23.20.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 20:52:25 -0700 (PDT) Date: Mon, 23 Oct 2023 23:52:25 -0400 Message-ID: From: Paul Moore To: Fan Wu , corbet@lwn.net, zohar@linux.ibm.com, jmorris@namei.org, serge@hallyn.com, tytso@mit.edu, ebiggers@kernel.org, axboe@kernel.dk, agk@redhat.com, snitzer@kernel.org, eparis@redhat.com Cc: linux-doc@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, audit@vger.kernel.org, roberto.sassu@huawei.com, linux-kernel@vger.kernel.org, Deven Bowers , Fan Wu Subject: Re: [PATCH RFC v11 5/19] ipe: introduce 'boot_verified' as a trust provider References: <1696457386-3010-6-git-send-email-wufan@linux.microsoft.com> In-Reply-To: <1696457386-3010-6-git-send-email-wufan@linux.microsoft.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 23 Oct 2023 20:54:24 -0700 (PDT) On Oct 4, 2023 Fan Wu wrote: > > IPE is designed to provide system level trust guarantees, this usually > implies that trust starts from bootup with a hardware root of trust, > which validates the bootloader. After this, the bootloader verifies the > kernel and the initramfs. > > As there's no currently supported integrity method for initramfs, and > it's typically already verified by the bootloader, introduce a property > that causes the first superblock to have an execution to be "pinned", > which is typically initramfs. > > When the "pinned" device is unmounted, it will be "unpinned" and > `boot_verified` property will always evaluate to false afterward. > > We use a pointer with a spin_lock to "pin" the device instead of rcu > because rcu synchronization may sleep, which is not allowed when > unmounting a device. > > Signed-off-by: Deven Bowers > Signed-off-by: Fan Wu > --- > v2: > +No Changes > > v3: > + Remove useless caching system > + Move ipe_load_properties to this match > + Minor changes from checkpatch --strict warnings > > v4: > + Remove comments from headers that was missed previously. > + Grammatical corrections. > > v5: > + No significant changes > > v6: > + No changes > > v7: > + Reword and refactor patch 04/12 to [09/16], based on changes in the underlying system. > + Add common audit function for boolean values > + Use common audit function as implementation. > > v8: > + No changes > > v9: > + No changes > > v10: > + Replace struct file with struct super_block > > v11: > + Fix code style issues > --- > security/ipe/eval.c | 72 +++++++++++++++++++++++++++++++++++- > security/ipe/eval.h | 2 + > security/ipe/hooks.c | 12 ++++++ > security/ipe/hooks.h | 2 + > security/ipe/ipe.c | 1 + > security/ipe/policy.h | 2 + > security/ipe/policy_parser.c | 35 +++++++++++++++++- > 7 files changed, 124 insertions(+), 2 deletions(-) > > diff --git a/security/ipe/eval.c b/security/ipe/eval.c > index 8a8bcc5c7d7f..bdac4abc0ddb 100644 > --- a/security/ipe/eval.c > +++ b/security/ipe/eval.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > > #include "ipe.h" > #include "eval.h" > @@ -16,6 +17,44 @@ > > struct ipe_policy __rcu *ipe_active_policy; > > +static const struct super_block *pinned_sb; > +static DEFINE_SPINLOCK(pin_lock); > +#define FILE_SUPERBLOCK(f) ((f)->f_path.mnt->mnt_sb) > + > +/** > + * pin_sb - Pin the underlying superblock of @f, marking it as trusted. > + * @sb: Supplies a super_block structure to be pinned. > + */ > +static void pin_sb(const struct super_block *sb) > +{ > + if (!sb) > + return; > + spin_lock(&pin_lock); > + if (!pinned_sb) > + pinned_sb = sb; > + spin_unlock(&pin_lock); > +} > + > +/** > + * from_pinned - Determine whether @sb is the pinned super_block. > + * @sb: Supplies a super_block to check against the pinned super_block. > + * > + * Return: > + * * true - @sb is the pinned super_block > + * * false - @sb is not the pinned super_block > + */ > +static bool from_pinned(const struct super_block *sb) > +{ > + bool rv; > + > + if (!sb) > + return false; > + spin_lock(&pin_lock); > + rv = !IS_ERR_OR_NULL(pinned_sb) && pinned_sb == sb; > + spin_unlock(&pin_lock); It's okay for an initial version, but I still think you need to get away from this spinlock in from_pinned() as quickly as possible. Maybe I'm wrong, but this looks like a major source of lock contention. I understand the issue around RCU and the potential for matching on a reused buffer/address, but if you modified IPE to have its own LSM security blob in super_block::security you could mark the superblock when it was mounted and do a lockless lookup here in from_pinned(). > + return rv; > +} -- paul-moore.com