[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yxl8Mq9x0JzaZwOz@kernel.org>
Date: Thu, 8 Sep 2022 08:22:58 +0300
From: Jarkko Sakkinen <jarkko@...nel.org>
To: Evan Green <evgreen@...omium.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Gwendal Grignou <gwendal@...omium.org>,
Eric Biggers <ebiggers@...nel.org>,
Matthew Garrett <mgarrett@...ora.tech>, zohar@...ux.ibm.com,
linux-integrity@...r.kernel.org, Pavel Machek <pavel@....cz>,
apronin@...omium.org, Daniil Lunev <dlunev@...gle.com>,
"Rafael J. Wysocki" <rjw@...ysocki.net>,
Linux PM <linux-pm@...r.kernel.org>,
Jonathan Corbet <corbet@....net>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
Matthew Garrett <matthewgarrett@...gle.com>,
Matthew Garrett <mjg59@...gle.com>, Hao Wu <hao.wu@...rik.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Peter Huewe <peterhuewe@....de>, axelj <axelj@...s.com>
Subject: Re: [PATCH v2 01/10] tpm: Add support for in-kernel resetting of PCRs
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@...nel.org> wrote:
> >
> > On Tue, Aug 23, 2022 at 03:25:17PM -0700, Evan Green wrote:
> > > From: Matthew Garrett <matthewgarrett@...gle.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@...gle.com>
> >
> > This is probably here by mistake.
> >
> > > Signed-off-by: Matthew Garrett <mjg59@...gle.com>
> > >
> >
> > No empty line here.
> >
> > > Signed-off-by: Evan Green <evgreen@...omium.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
Powered by blists - more mailing lists