All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Masahisa Kojima <masahisa.kojima@linaro.org>,
	Alexander Graf <agraf@csgraf.de>, Simon Glass <sjg@chromium.org>,
	u-boot@lists.denx.de,
	AKASHI Takahiro <takahiro.akashi@linaro.org>
Subject: Re: [PATCH 3/3] efi_loader: fix efi_tcg2_hash_log_extend_event() parameter check
Date: Fri, 3 Sep 2021 09:51:31 +0300	[thread overview]
Message-ID: <YTHF80zRDOjrc6Qk@apalos.home> (raw)
In-Reply-To: <27ce80c5-5f79-0789-f965-1bd09644d744@gmx.de>

Hi Heinrich,

On Fri, Sep 03, 2021 at 08:22:30AM +0200, Heinrich Schuchardt wrote:
> On 9/3/21 3:55 AM, Masahisa Kojima wrote:
> > TCG EFI Protocol Specification defines that PCRIndex parameter
> > passed from caller must be 0 to 23.
> > TPM2_MAX_PCRS is currently used to check the range of PCRIndex,
> > but TPM2_MAX_PCRS is tpm2 device dependent and may have larger value.
> > This commit newly adds EFI_TCG2_MAX_PCR_INDEX macro, it is used to
> > check the range of PCRIndex parameter.
> 
> In the U-Boot code we have TPM2_MAX_PCRS hard coded as 32. Can the value
> be less?

This is defined in [1] 
[1] https://trustedcomputinggroup.org/wp-content/uploads/TSS_Overview_Common_v0p9_r10_12june2021.pdf

> 
> > 
> > Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
> > ---
> >   include/efi_tcg2.h        | 2 ++
> >   lib/efi_loader/efi_tcg2.c | 2 +-
> >   2 files changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/efi_tcg2.h b/include/efi_tcg2.h
> > index 45788d55d5..b647361d44 100644
> > --- a/include/efi_tcg2.h
> > +++ b/include/efi_tcg2.h
> > @@ -28,6 +28,8 @@
> >   #define EFI_TCG2_EXTEND_ONLY 0x0000000000000001
> >   #define PE_COFF_IMAGE 0x0000000000000010
> > 
> > +#define EFI_TCG2_MAX_PCR_INDEX 23
> > +
> >   /* Algorithm Registry */
> >   #define EFI_TCG2_BOOT_HASH_ALG_SHA1    0x00000001
> >   #define EFI_TCG2_BOOT_HASH_ALG_SHA256  0x00000002
> > diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
> > index c4e9f61fd6..b268a02976 100644
> > --- a/lib/efi_loader/efi_tcg2.c
> > +++ b/lib/efi_loader/efi_tcg2.c
> > @@ -958,7 +958,7 @@ efi_tcg2_hash_log_extend_event(struct efi_tcg2_protocol *this, u64 flags,
> >   		goto out;
> >   	}
> > 
> > -	if (efi_tcg_event->header.pcr_index > TPM2_MAX_PCRS) {
> 
> If TPM2_MAX_PCRS were device dependent and could be less then 23 we
> would need a check against both constants.
> 
> Could you, please, clarify the issue. If TPM2_MAX_PCRS is always greater
> then 23, please, mention this in the commit message and perhaps add a
> comment in the code here.

You don't need that (I think). If the spec says you have to check against
23, then that's what Kojima-san fixes here. 
If the device supports less than 23, then the current code as-is will
return EFI_DEVICE_ERROR, in case the device has less than 23 PCRs. 

We could ofc just check against the value we get from GetCapability, which
would be correct as well?

> 
> Best regards
> 
> Heinrich
> 
> > +	if (efi_tcg_event->header.pcr_index > EFI_TCG2_MAX_PCR_INDEX) {
> >   		ret = EFI_INVALID_PARAMETER;
> >   		goto out;
> >   	}
> > 

[1] https://trustedcomputinggroup.org/wp-content/uploads/TSS_Overview_Common_v0p9_r10_12june2021.pdf

Regards
/Ilias

  reply	other threads:[~2021-09-03  6:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03  1:55 [PATCH 0/3] Miscellaneous fixes of efi_tcg2 Masahisa Kojima
2021-09-03  1:55 ` [PATCH 1/3] efi_loader: add missing parameter check for EFI_TCG2_PROTOCOL api Masahisa Kojima
2021-09-03  6:25   ` Ilias Apalodimas
2021-09-03  1:55 ` [PATCH 2/3] efi_loader: fix boot_service_capability_min calculation Masahisa Kojima
2021-09-03  6:19   ` Ilias Apalodimas
2021-09-03  7:01   ` Heinrich Schuchardt
2021-09-03  7:24     ` Masahisa Kojima
2021-09-03  1:55 ` [PATCH 3/3] efi_loader: fix efi_tcg2_hash_log_extend_event() parameter check Masahisa Kojima
2021-09-03  6:20   ` Ilias Apalodimas
2021-09-03  6:22   ` Heinrich Schuchardt
2021-09-03  6:51     ` Ilias Apalodimas [this message]
2021-09-03  7:11       ` Heinrich Schuchardt

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=YTHF80zRDOjrc6Qk@apalos.home \
    --to=ilias.apalodimas@linaro.org \
    --cc=agraf@csgraf.de \
    --cc=masahisa.kojima@linaro.org \
    --cc=sjg@chromium.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.