linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Evan Green <evgreen@chromium.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Gwendal Grignou <gwendal@chromium.org>,
	Eric Biggers <ebiggers@kernel.org>,
	Matthew Garrett <mgarrett@aurora.tech>,
	zohar@linux.ibm.com, linux-integrity@vger.kernel.org,
	Pavel Machek <pavel@ucw.cz>,
	apronin@chromium.org, Daniil Lunev <dlunev@google.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux PM <linux-pm@vger.kernel.org>,
	Jonathan Corbet <corbet@lwn.net>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	Matthew Garrett <matthewgarrett@google.com>,
	Matthew Garrett <mjg59@google.com>, Hao Wu <hao.wu@rubrik.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Peter Huewe <peterhuewe@gmx.de>,
	axelj <axelj@axis.com>
Subject: Re: [PATCH v2 01/10] tpm: Add support for in-kernel resetting of PCRs
Date: Thu, 8 Sep 2022 08:22:58 +0300	[thread overview]
Message-ID: <Yxl8Mq9x0JzaZwOz@kernel.org> (raw)
In-Reply-To: <CAE=gft6RuggyTSJXty5EskUcwLFEv4mrC1AL3HY-UgvXQRxvbA@mail.gmail.com>

On Wed, Sep 07, 2022 at 10:02:14AM -0700, Evan Green wrote:
> On Thu, Aug 25, 2022 at 8:00 PM Jarkko Sakkinen <jarkko@kernel.org> wrote:
> >
> > On Tue, Aug 23, 2022 at 03:25:17PM -0700, Evan Green wrote:
> > > From: Matthew Garrett <matthewgarrett@google.com>
> > >
> > > 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 <mjg59@google.com>
> >
> > This is probably here by mistake.
> >
> > > Signed-off-by: Matthew Garrett <mjg59@google.com>
> > >
> >
> > No empty line here.
> >
> > > Signed-off-by: Evan Green <evgreen@chromium.org>
> > > ---
> > > 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

  reply	other threads:[~2022-09-08  5:23 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 22:25 [PATCH v2 00/10] Encrypted Hibernation Evan Green
2022-08-23 22:25 ` [PATCH v2 01/10] tpm: Add support for in-kernel resetting of PCRs Evan Green
2022-08-26  2:59   ` Jarkko Sakkinen
2022-09-07 17:02     ` Evan Green
2022-09-08  5:22       ` Jarkko Sakkinen [this message]
2022-08-23 22:25 ` [PATCH v2 02/10] tpm: Allow PCR 23 to be restricted to kernel-only use Evan Green
2022-08-26  3:02   ` Jarkko Sakkinen
2022-09-07 17:03     ` Evan Green
2022-09-13 12:26   ` Stefan Berger
2022-09-20  4:50     ` Jarkko Sakkinen
2022-09-21 15:35       ` Evan Green
2022-09-21 18:02         ` Jarkko Sakkinen
2022-09-21 18:05           ` Jarkko Sakkinen
2022-09-21 19:02             ` Evan Green
2022-08-23 22:25 ` [PATCH v2 03/10] security: keys: trusted: Include TPM2 creation data Evan Green
2022-09-20 23:04   ` Kees Cook
2022-09-23 22:22     ` Evan Green
2022-08-23 22:25 ` [PATCH v2 04/10] security: keys: trusted: Allow storage of PCR values in " Evan Green
2022-08-24 11:56   ` Ben Boeckel
2022-08-24 17:34     ` Evan Green
2022-08-23 22:25 ` [PATCH v2 05/10] security: keys: trusted: Verify " Evan Green
2022-09-20 23:06   ` Kees Cook
2022-09-23 22:23     ` Evan Green
2022-08-23 22:25 ` [PATCH v2 06/10] PM: hibernate: Add kernel-based encryption Evan Green
2022-09-20 23:09   ` Kees Cook
2022-08-23 22:25 ` [PATCH v2 07/10] PM: hibernate: Use TPM-backed keys to encrypt image Evan Green
2022-09-20 23:16   ` Kees Cook
2022-09-23 22:23     ` Evan Green
2022-09-24  4:31       ` Kees Cook
2022-08-23 22:25 ` [PATCH v2 08/10] PM: hibernate: Mix user key in encrypted hibernate Evan Green
2022-08-23 22:25 ` [PATCH v2 09/10] PM: hibernate: Verify the digest encryption key Evan Green
2022-08-23 22:25 ` [PATCH v2 10/10] PM: hibernate: seal the encryption key with a PCR policy Evan Green
2022-09-20 23:24   ` Kees Cook
2022-08-31 18:34 ` [PATCH v2 00/10] Encrypted Hibernation Limonciello, Mario
2022-09-07 17:03   ` Evan Green
2022-09-20  8:46 ` Pavel Machek
2022-09-20 16:39   ` Evan Green
2022-09-21 18:09   ` Jason Gunthorpe
2022-09-20 22:52 ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yxl8Mq9x0JzaZwOz@kernel.org \
    --to=jarkko@kernel.org \
    --cc=apronin@chromium.org \
    --cc=axelj@axis.com \
    --cc=corbet@lwn.net \
    --cc=dlunev@google.com \
    --cc=ebiggers@kernel.org \
    --cc=evgreen@chromium.org \
    --cc=gwendal@chromium.org \
    --cc=hao.wu@rubrik.com \
    --cc=jejb@linux.ibm.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=matthewgarrett@google.com \
    --cc=mgarrett@aurora.tech \
    --cc=mjg59@google.com \
    --cc=pavel@ucw.cz \
    --cc=peterhuewe@gmx.de \
    --cc=rjw@rjwysocki.net \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).