Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1638097rda; Mon, 23 Oct 2023 20:54:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/FV3wzjuMg3uuBKa0rfAdjUxzyVnfzYV43T5kIEmbI5cSiQnjn2HIxGqo2ewhkhShnXLG X-Received: by 2002:a05:6830:3484:b0:6c0:f451:ab6a with SMTP id c4-20020a056830348400b006c0f451ab6amr17973343otu.8.1698119670947; Mon, 23 Oct 2023 20:54:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698119670; cv=none; d=google.com; s=arc-20160816; b=Ds/GuqG1cMJ+KffPcu9zYyGM/ArUApeGqx8dDnZt2jJB5QpZqhqkpJ9zlXvzegl/UD eQ7YVMQu3I3pY4ussOLZVtfiF4z3ogmvh+XOknMrdJdTXsg2G0K/+MCP1OIkO9h0GYtB A3GwaBqlML4Owpxow3P4rTh1WmsSfgO1FLVmkq6b0cxeYtTEnEQsJ32ENphCoFtReDj6 X01tFVpX17CP5R8SsFvPLQ4fVOCS9u8Dh5mOCrnYCWRz3HdULPAuJmyzFz4qA46vm0Rz qmsfY6woWQA8pkpNut4JjWUPd+t/aXTI4cLoY2cE7u4kxivsN7bfJYsHA+7wOELSD10h tDFw== 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=55ZRJ15k5rlJjmFui052IxveaRjJKA9VJGl0uzNotB8=; fh=L/xvHrPlacKOsJv3vvO5q8j3vb/kgyy54coe2Vjk9io=; b=FbV7Wmhnfmhdq/WIVHCEqH88QfFEz7YKbhqooAcgH7VRE4X01rak4T2n5u79fo8gLv sXOaP//i4W6H+1lhCNc/YoYrM7F0hxZY4GOdT7MFbFgh+GcHbhd8OFF7Z2CwYFEZ673a zh6JuPq8Y6Sptcg5WJYmVVi2s9qoUXD16FJd8CTV0mb5Ajcxh7Vw5soeyewx5iSi9KiY PPcP87dtITKymOKg3lmUDUgjtrwFPk3+NQ+kiB8HT6fwfOZI20E8/XmY81Zhm/HUdvLU Mig+sCLYUS44zd7xq2y5jsdu+HBaTKFDVZ+P2s/vnebY6BcQv3ykEx9XR3QSrHzIip7V W4EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=NOsjfUsi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bw34-20020a056a0204a200b005a9fb6bf73esi8020510pgb.293.2023.10.23.20.54.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 20:54:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=NOsjfUsi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 597A6802F946; Mon, 23 Oct 2023 20:54:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232449AbjJXDyB (ORCPT + 99 others); Mon, 23 Oct 2023 23:54:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232384AbjJXDws (ORCPT ); Mon, 23 Oct 2023 23:52:48 -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 984F0170D for ; Mon, 23 Oct 2023 20:52:36 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-778a20df8c3so281477485a.3 for ; Mon, 23 Oct 2023 20:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1698119555; x=1698724355; 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=55ZRJ15k5rlJjmFui052IxveaRjJKA9VJGl0uzNotB8=; b=NOsjfUsiwJ6iZkl1CzbXPwvgzAEyZ3ahiAQdcJtdRzTg1KxCLIflQ32IHGJXELMhe5 XYZf6o62nBC47jGKfMuZhXz0tFU239x9gsK2mBXcfdav0bjk+8I5c+GYS1hYNieD0Cz+ zpatyfzG0HJIRkkMc+BJAPtiG0N+2G1oWAnQ33ujxNuvs5QGupUEirFdGtFE7zJA5nwa fxgjJsU9y5d9HAAcnGSWHyjdv4A2FAqwC+h5Hz2z7gIG80oeDnprAdkDTZpl1pgEufGj cjObeC16eeFfiC6/mXIaWl1BUmjoVswgU5kOFiAANUcwpw2JSTd5cEGjqU1IXitMBtVS tNEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698119555; x=1698724355; 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=55ZRJ15k5rlJjmFui052IxveaRjJKA9VJGl0uzNotB8=; b=LRxhO8qAsQbfzuY/Ve3EmZ6Erm9sPIfgdumwcF5Ob2NvcGq1mqJwP7jWE4bEua9OAZ RvjGqyvYh52C/7ZgT7YvRgKnng565GuQFbEvjytw4qzyqe7P/Q3KuKByOQH+qDl9znTE fo3Ss2maAhPeFiEYEEDQ6vTpYc1dBdxfFW9tzJoUWn79nVqN41PWrnMCrWhgl39ojwMT uaqtvlPOU/iwkQZ8bjn5m+n1nlIS1IlUvLgXtU6YopNjY6oR6bfz08/jwA8iunw5aELB JawMnzUh60EbZuSOChtsVjtHE2URagwJTQaHa6tV6neFHxGONvgdwMTLUdN1cyE2H29d wpwg== X-Gm-Message-State: AOJu0YzqUm3VDFqCBcRkgXUgir/6UsR3sA6orTAQwY10EXYCPc8L62/2 tYb9K/oSpSDIYmWGMfe1FRrt X-Received: by 2002:a05:6214:626:b0:66d:5dec:6099 with SMTP id a6-20020a056214062600b0066d5dec6099mr11383093qvx.41.1698119555528; Mon, 23 Oct 2023 20:52:35 -0700 (PDT) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id ee3-20020a0562140a4300b0065b260eafd9sm3357598qvb.87.2023.10.23.20.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 20:52:34 -0700 (PDT) Date: Mon, 23 Oct 2023 23:52:34 -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, Fan Wu , Deven Bowers Subject: Re: [PATCH RFC v11 16/19] ipe: enable support for fs-verity as a trust provider References: <1696457386-3010-17-git-send-email-wufan@linux.microsoft.com> In-Reply-To: <1696457386-3010-17-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 23 Oct 2023 20:54:28 -0700 (PDT) On Oct 4, 2023 Fan Wu wrote: > > Enable IPE policy authors to indicate trust for a singular fsverity > file, identified by the digest information, through "fsverity_digest" > and all files using fsverity's builtin signatures via > "fsverity_signature". > > This enables file-level integrity claims to be expressed in IPE, > allowing individual files to be authorized, giving some flexibility > for policy authors. Such file-level claims are important to be expressed > for enforcing the integrity of packages, as well as address some of the > scalability issues in a sole dm-verity based solution (# of loop back > devices, etc). > > This solution cannot be done in userspace as the minimum threat that > IPE should mitigate is an attacker downloads malicious payload with > all required dependencies. These dependencies can lack the userspace > check, bypassing the protection entirely. A similar attack succeeds if > the userspace component is replaced with a version that does not > perform the check. As a result, this can only be done in the common > entry point - the kernel. > > Signed-off-by: Deven Bowers > Signed-off-by: Fan Wu > --- > v1-v6: > + Not present > > v7: > Introduced > > v8: > * Undo squash of 08/12, 10/12 - separating drivers/md/ from security/ > * Use common-audit function for fsverity_signature. > + Change fsverity implementation to use fsverity_get_digest > + prevent unnecessary copy of fs-verity signature data, instead > just check for presence of signature data. > + Remove free_inode_security hook, as the digest is now acquired > at runtime instead of via LSM blob. > > v9: > + Adapt to the new parser > > v10: > + Update the fsverity get digest call > > v11: > + No changes > --- > security/ipe/Kconfig | 13 +++++ > security/ipe/audit.c | 23 ++++++++ > security/ipe/eval.c | 110 +++++++++++++++++++++++++++++++++++ > security/ipe/eval.h | 10 ++++ > security/ipe/hooks.c | 30 ++++++++++ > security/ipe/hooks.h | 7 +++ > security/ipe/ipe.c | 13 +++++ > security/ipe/ipe.h | 3 + > security/ipe/policy.h | 3 + > security/ipe/policy_parser.c | 8 +++ > 10 files changed, 220 insertions(+) ... > diff --git a/security/ipe/audit.c b/security/ipe/audit.c > index b5c58655ac74..e3a8552a76a4 100644 > --- a/security/ipe/audit.c > +++ b/security/ipe/audit.c > @@ -79,6 +100,8 @@ static void audit_rule(struct audit_buffer *ab, const struct ipe_rule *r) > audit_log_format(ab, "%s", audit_prop_names[ptr->type]); > if (ptr->type == IPE_PROP_DMV_ROOTHASH) > audit_dmv_roothash(ab, ptr->value); > + if (ptr->type == IPE_PROP_FSV_DIGEST) > + audit_fsv_digest(ab, ptr->value); My comments on audit_dmv_roothash() also apply here. > audit_log_format(ab, " "); > } > diff --git a/security/ipe/eval.c b/security/ipe/eval.c > index 82ad48d7aa3d..f0194b0ca2ff 100644 > --- a/security/ipe/eval.c > +++ b/security/ipe/eval.c > @@ -172,6 +191,91 @@ static bool evaluate_dmv_sig_true(const struct ipe_eval_ctx *const ctx, > } > #endif /* CONFIG_IPE_PROP_DM_VERITY */ > > +#ifdef CONFIG_IPE_PROP_FS_VERITY > +/** > + * evaluate_fsv_digest - Analyze @ctx against a fsv digest property. > + * @ctx: Supplies a pointer to the context being evaluated. > + * @p: Supplies a pointer to the property being evaluated. > + * > + * Return: > + * * true - The current @ctx match the @p > + * * false - The current @ctx doesn't match the @p > + */ > +static bool evaluate_fsv_digest(const struct ipe_eval_ctx *const ctx, > + struct ipe_prop *p) > +{ > + enum hash_algo alg; > + u8 digest[FS_VERITY_MAX_DIGEST_SIZE]; > + > + if (!ctx->ino) > + return false; > + if (!fsverity_get_digest((struct inode *)ctx->ino, > + digest, > + NULL, > + &alg)) > + return false; > + > + return ipe_digest_eval(p->value, > + digest, > + hash_digest_size[alg], > + hash_algo_name[alg]); > +} > + > +/** > + * evaluate_fsv_sig_false - Analyze @ctx against a fsv sig false property. > + * @ctx: Supplies a pointer to the context being evaluated. > + * @p: Supplies a pointer to the property being evaluated. > + * > + * Return: > + * * true - The current @ctx match the @p > + * * false - The current @ctx doesn't match the @p > + */ > +static bool evaluate_fsv_sig_false(const struct ipe_eval_ctx *const ctx, > + struct ipe_prop *p) > +{ > + return !ctx->ino || > + !IS_VERITY(ctx->ino) || > + !ctx->ipe_inode || > + !ctx->ipe_inode->fs_verity_signed; > +} > + > +/** > + * evaluate_fsv_sig_true - Analyze @ctx against a fsv sig true property. > + * @ctx: Supplies a pointer to the context being evaluated. > + * @p: Supplies a pointer to the property being evaluated. > + * > + * Return: > + * * true - The current @ctx match the @p > + * * false - The current @ctx doesn't match the @p > + */ > +static bool evaluate_fsv_sig_true(const struct ipe_eval_ctx *const ctx, > + struct ipe_prop *p) > +{ > + return ctx->ino && > + IS_VERITY(ctx->ino) && > + ctx->ipe_inode && > + ctx->ipe_inode->fs_verity_signed; > +} See my previous comments about the false/true functions. > +#else -- paul-moore.com