Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp166342rwn; Wed, 7 Sep 2022 22:41:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR4+BD4CeRUxqg1hyKH6CETYS6JMBxeNNEkO21oLyVe7ZAMIYM9jt2JIUm0Tbb+0L2w+TMSu X-Received: by 2002:a17:906:959:b0:741:6f76:546f with SMTP id j25-20020a170906095900b007416f76546fmr5001300ejd.32.1662615711601; Wed, 07 Sep 2022 22:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662615711; cv=none; d=google.com; s=arc-20160816; b=IVHS3End/YxZOzRsayXjbxnne+uhwAQDczNElOUhHRwe2geh24Os/0m0I0fPljaolr nbFMbrjNQJ1Ngf/fBHUN8CeqVW7JedT+9V/hSRqJx6vSrJsm2z+SMfCbQO6nGjEcqk/v a8kFLsVytenjWG/Jm7ZjY0HLOxfSPanHmtVULhGw0erjQQlNZ/9I+fq79uPb5EAbJwpy n1Ywa99aq0uD7ytsM87sMnxR/SxFHt9MKlX7qVEOXf9UDU7EWDMPkW18g8iuBUbQbKeI mGLYdCRFPWuTbZckcTtkJwljRRwLuq3pRjtsGPDx50BU00vlSHp6qGMDYcGEWPS3f1u4 6Ypg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8kXQOpsFVWv7nP7QBvmk3Dhz7yHiTjasBAecBt9AVJ0=; b=xAgQj8B6HDQd8UKDV5gCbxiqyutUFpxhKU/UhatllcYlSD4wsYmqboKvPt7U2OgNiq uNwda/d3Uieh7fWoetWyeqMwp3+Pf/YT3xWVBRCTEXSnO2LIlTPoiw0KOLkKZVGWFf6R Bbsop6WImnINUKiCt/pAPGIwCSoWwQ4XGHgvJIkgWrftEn1o4pwCcYstfpPuFjMkfRhc USdhUbsi4MDxVMaQTiKfFLqHEWkc1PpZ9JdLX5mGtEbSP9kOnUtjdS5e5Q+GccqWlqg3 gWDNYNuHjj2DJ8qqGCkjQgbKF8p51C8Bx9tW1DVOXzM+k6AMSSxSnHcgtsbaZiq9kRbn 9jdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LgD0LbNR; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc14-20020a170906f90e00b0072abb95e8e4si1224513ejb.598.2022.09.07.22.41.26; Wed, 07 Sep 2022 22:41:51 -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=@kernel.org header.s=k20201202 header.b=LgD0LbNR; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230000AbiIHFXI (ORCPT + 99 others); Thu, 8 Sep 2022 01:23:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbiIHFXG (ORCPT ); Thu, 8 Sep 2022 01:23:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6757AC1655; Wed, 7 Sep 2022 22:23:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E129261AA9; Thu, 8 Sep 2022 05:23:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F12F0C433C1; Thu, 8 Sep 2022 05:23:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662614584; bh=SgYV8YgFSca0cWdtkHTBPwtsnwvrNOzmuu9r5QTID2M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LgD0LbNRs1V+eSL4xF1howywVgSAYf9nJgi4of/DN97o2cyssBwxeSr06qV9SPmDl d+szMgjWGJ9mzgeCbKCK3bWjxczd8S9FL/92jWuH8AbxwEJdv6D6sIJQDnCEV7Ivxt j+nKx6fKtuXHHR4pAumwUgSX6lVVD9AqHi3hX/0thLy/SKQtcVrFFGcgma15oRzwGd MDN+hCEPvtfCnLslXp1mQ5fbY4ynQ2jcEEHeTgDxaYmtIKhufrck258MoSlGh6csdM KRyxxiltZdBFXpMb/Axb14s7zNzqNAt4Qbw4VKykp1XSM1VU4tBCv11qy3buJ8TTmf dM+x4bnhOunbQ== Date: Thu, 8 Sep 2022 08:22:58 +0300 From: Jarkko Sakkinen To: Evan Green 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 Subject: Re: [PATCH v2 01/10] tpm: Add support for in-kernel resetting of PCRs Message-ID: References: <20220823222526.1524851-1-evgreen@chromium.org> <20220823152108.v2.1.I776854f47e3340cc2913ed4d8ecdd328048b73c3@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Wed, Sep 07, 2022 at 10:02:14AM -0700, Evan Green wrote: > 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 Yeah, I think it'd be a good idea. BR, Jarkko