Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5948233rwb; Wed, 7 Sep 2022 10:13:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR5WDwnZwpizHFHRJI12MiksygGo2FjsvgxMQKlIXQYelyzcdtvfwlYOCUAi/cmNMmhjB39C X-Received: by 2002:a17:903:2104:b0:176:a9ef:418b with SMTP id o4-20020a170903210400b00176a9ef418bmr4848159ple.134.1662570839357; Wed, 07 Sep 2022 10:13:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662570839; cv=none; d=google.com; s=arc-20160816; b=C5pHZajNT7fbFiiXAwJWsmd4gjCGv4jKmJWpKtqZcxg7gZRIvq77m8VnvEVuUc9bfH xErpF1TwX7pSpdRmuF5m0ZRzPeZdfiP8VWnfG9C90SXS/YrdqkX/1j2MjiTMcCyDvsVS iMQKI9ofWSf5vcXQCy8uWJ/H4dhQCno/dS3k2fWc3Kv+iyYySCXZS2PL2osdhxdYMGZn kPgs+WJ9Z9CiT+NE0S2ri6AVU5s1Dsta4Elg809X0Z3zXDSlPW0qdL0xvgaRuGg/PUIx kZR6bvLXlr6At2qSbrYq4ZWFjOzFyBeU/tHc5A4iy/R86b0gDD2bd4SXaEiCGsmlfb9N v6Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=QHc+dzwrG9zhOQ7C4s6n1WTuaaXkQxEQESnpVWN4LoI=; b=kn/yeUSRXqj4TIPIUl1wdEP0PnmU5sAR8+TzBdbnkvj3LSdea4vf9q9yDRVtS+fYt1 s5Uka5ww2RNKaVOupkFUWYSPiO2hsu8l1PZFCuQatQFjvXNsbPy/9E4RHoRfrtbj5g3J 6ENXiBo/bX0NXldHWgQBRPGjwjmklheMSH21LF6mKvjT5e4BhTuyVkrHBtHBB+ouA0cm 6+x3ercOqK9YeQQGYcd78XfQfqoniKFQcZfq77h2kckO0rK1h42Kgj5/1rC9Gvk3C1RW 355Lm2Nu3iEjzKpbzg069+y7iMqWBtBGYYdYO8mKsvX+5tOdatWLbovcMMpkKq8AGID1 QmpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lW22XNnE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go17-20020a17090b03d100b002007911fcc2si7732489pjb.28.2022.09.07.10.13.47; Wed, 07 Sep 2022 10:13:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lW22XNnE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230258AbiIGRLI (ORCPT + 99 others); Wed, 7 Sep 2022 13:11:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229916AbiIGRKb (ORCPT ); Wed, 7 Sep 2022 13:10:31 -0400 Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5919BC13D for ; Wed, 7 Sep 2022 10:10:23 -0700 (PDT) Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-1278624b7c4so19399852fac.5 for ; Wed, 07 Sep 2022 10:10:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=QHc+dzwrG9zhOQ7C4s6n1WTuaaXkQxEQESnpVWN4LoI=; b=lW22XNnE/dd1CgVKzegBWEnUGdTcs6CZNzVN8GMT1yOwlH8Pg4axoGlYV2xDdjyrUl 9vibGJ3Dids+Hk/xfei2pRRtSi4peEJRmJGUeSxuzU4Smgi5aIHfLjxki3tehWJ34DSv 5KV/pnWH1GO9Tl3kROCcfqUWiSl7OmivZTkzw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=QHc+dzwrG9zhOQ7C4s6n1WTuaaXkQxEQESnpVWN4LoI=; b=vgCpc41ReyfccdFg5GNLHlECDg2LxxkiGofeHAPp3cFjBsfJu2B/3Yhmx2QYyF0TRA INk4gCethDS+eCj/w1CankZkVxVw0IQb6QYlAWWn/IjVzfANev2yFCSSPQjcdfl+e5wW cd1pAG4MxcR0YgX6yZ88yn291X3tMKHyHqRUzPze21fGc6nPQKNQVc4yi2dA7Jj4YkLx 4adC98lutFB1PJ5csO64pCKQawmxt9Imh936WECbj7szoxVGVXdVtOUMPoJzaoPbTJfo DXRij/yCPyN6PbUVyLS/3qQD6crIb2cOII45TP05RIuk2dq8Az4bzMvf5+KBM8JheXZO GWSA== X-Gm-Message-State: ACgBeo3BhBpJGeKOFaAAjJ70580a1U/WCGiu9/gxVUGc749g2aXUZ4MC /+QfLSwKBMvkN1wo6fGgPCXEBG6zoZW2FQ== X-Received: by 2002:a05:6808:1508:b0:344:a3be:c582 with SMTP id u8-20020a056808150800b00344a3bec582mr2092219oiw.205.1662570622888; Wed, 07 Sep 2022 10:10:22 -0700 (PDT) Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com. [209.85.160.52]) by smtp.gmail.com with ESMTPSA id be36-20020a05687058a400b000f5e89a9c60sm8837139oab.3.2022.09.07.10.10.22 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Sep 2022 10:10:22 -0700 (PDT) Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-127f5411b9cso6288104fac.4 for ; Wed, 07 Sep 2022 10:10:22 -0700 (PDT) X-Received: by 2002:a05:6808:3096:b0:342:ff93:4672 with SMTP id bl22-20020a056808309600b00342ff934672mr2052129oib.174.1662570170769; Wed, 07 Sep 2022 10:02:50 -0700 (PDT) MIME-Version: 1.0 References: <20220823222526.1524851-1-evgreen@chromium.org> <20220823152108.v2.1.I776854f47e3340cc2913ed4d8ecdd328048b73c3@changeid> In-Reply-To: From: Evan Green Date: Wed, 7 Sep 2022 10:02:14 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 01/10] tpm: Add support for in-kernel resetting of PCRs To: Jarkko Sakkinen Cc: LKML , Gwendal Grignou , Eric Biggers , Matthew Garrett , zohar@linux.ibm.com, linux-integrity@vger.kernel.org, Pavel Machek , apronin@chromium.org, Daniil Lunev , "Rafael J. Wysocki" , Linux PM , Jonathan Corbet , "James E.J. Bottomley" , Matthew Garrett , Matthew Garrett , Hao Wu , Jason Gunthorpe , Peter Huewe , axelj Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 25, 2022 at 8:00 PM Jarkko Sakkinen wrote: > > On Tue, Aug 23, 2022 at 03:25:17PM -0700, Evan Green wrote: > > From: Matthew Garrett > > > > Add an internal command for resetting a PCR. This will be used by the > > encrypted hibernation code to set PCR23 to a known value. The > > hibernation code will seal the hibernation key with a policy specifying > > PCR23 be set to this known value as a mechanism to ensure that the > > hibernation key is genuine. But to do this repeatedly, resetting the PCR > > is necessary as well. > > > > From: Matthew Garrett > > This is probably here by mistake. > > > Signed-off-by: Matthew Garrett > > > > No empty line here. > > > Signed-off-by: Evan Green > > --- > > Matthew's original version of this patch was at: > > https://patchwork.kernel.org/patch/12096487/ > > > > (no changes since v1) > > > > drivers/char/tpm/tpm-interface.c | 28 +++++++++++++++++++++++++ > > drivers/char/tpm/tpm.h | 2 ++ > > drivers/char/tpm/tpm1-cmd.c | 34 ++++++++++++++++++++++++++++++ > > drivers/char/tpm/tpm2-cmd.c | 36 ++++++++++++++++++++++++++++++++ > > include/linux/tpm.h | 7 +++++++ > > 5 files changed, 107 insertions(+) > > > > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c > > index 1621ce8187052c..17b8643ee109c2 100644 > > --- a/drivers/char/tpm/tpm-interface.c > > +++ b/drivers/char/tpm/tpm-interface.c > > @@ -342,6 +342,34 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, > > } > > EXPORT_SYMBOL_GPL(tpm_pcr_extend); > > > > +/** > > + * tpm_pcr_reset - reset the specified PCR > > + * @chip: a &struct tpm_chip instance, %NULL for the default chip > > + * @pcr_idx: the PCR to be reset > > + * > > + * Return: same as with tpm_transmit_cmd() > > + */ > > +int tpm_pcr_reset(struct tpm_chip *chip, u32 pcr_idx) > > +{ > > + int rc; > > + > > + chip = tpm_find_get_ops(chip); > > + if (!chip) > > + return -ENODEV; > > + > > + if (chip->flags & TPM_CHIP_FLAG_TPM2) { > > + rc = tpm2_pcr_reset(chip, pcr_idx); > > + goto out; > > + } > > + > > + rc = tpm1_pcr_reset(chip, pcr_idx, "attempting to reset a PCR"); > > + > > +out: > > + tpm_put_ops(chip); > > if (chip->flags & TPM_CHIP_FLAG_TPM2) > rc = tpm2_pcr_reset(chip, pcr_idx); > else > rc = tpm1_pcr_reset(chip, pcr_idx, "attempting to reset a PCR"); > > Where does this asymmetry come with the parameters? Sorry for the delay, I was out last week. I think it's modeled to match the tpm1/2_pcr_extend functions, which have this same odd asymmetry. Should I change it to have both use the tpm2_pcr_reset() prototype? -Evan