From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E582AC54EE9 for ; Wed, 7 Sep 2022 17:11:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229924AbiIGRLK (ORCPT ); Wed, 7 Sep 2022 13:11:10 -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-Google-Smtp-Source: AA6agR6dEHp0safF0nxtTcGk04DB0J61wbY1oPBXeLglNeWhjUs32N2jzTkVeKxBdu3EyTXdHgSjxA== 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" 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