Linux-EFI Archive mirror
 help / color / mirror / Atom feed
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Ard Biesheuvel <ardb+git@google.com>,
	linux-efi@vger.kernel.org,
	 Kuppuswamy Sathyanarayanan
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH v3 1/5] efi/libstub: Use correct event size when measuring data into the TPM
Date: Fri, 8 Mar 2024 12:05:44 +0200	[thread overview]
Message-ID: <CAC_iWjL3yHt16vrwCh8V3FWqLRHJ07wt-pL2scB+2B8Y2AHgvg@mail.gmail.com> (raw)
In-Reply-To: <CAMj1kXFab6MqG+BZ64OSdfzcb-88-N0cwMGZ_bn3vC6NOhgCFw@mail.gmail.com>

On Fri, 8 Mar 2024 at 11:43, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Fri, 8 Mar 2024 at 10:38, Ilias Apalodimas
> <ilias.apalodimas@linaro.org> wrote:
> >
> > Hi Ard
> >
> > On Fri, 8 Mar 2024 at 10:58, Ard Biesheuvel <ardb+git@google.com> wrote:
> > >
> > > From: Ard Biesheuvel <ardb@kernel.org>
> > >
> > > Our efi_tcg2_tagged_event is not defined in the EFI spec, but it is not
> > > a local invention either: it was taken from the TCG PC Client spec,
> > > where it is called TCG_PCClientTaggedEvent.
> > >
> > > This spec also contains some guidance on how to populate it, which
> > > is not being followed closely at the moment; the event size should cover
> > > the TCG_PCClientTaggedEvent and its payload only, but it currently
> > > covers the preceding efi_tcg2_event too, and this may result in trailing
> > > garbage being measured into the TPM.
> >
> > I think there's a confusion here and the current code we have is correct.
> > The EFI TCG spec [0] says that the tdEFI_TCG2_EVENT size is:
> > "Total size of the event including the Size component, the header and the
> > Event data." which obviously contradicts the definition of the tagged
> > event in the PC client spec.
> > But given the fact that TCG_PCClientTaggedEvent has its own size field
> > I think we should use what we already have.
> >
> >
> > [0] https://trustedcomputinggroup.org/wp-content/uploads/EFI-Protocol-Specification-rev13-160330final.pdf
> > page 33
> >
>
> Fair enough.
>
> It is rather disappointing that the TCG2 specs contradict each other,

Indeed

> but a quick inspection of the EDK2 implementation shows that it
> follows your interpretation.
>
> For example, in Tcg2HashLogExtendEvent()
> [SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c], we have a check
>
> if (Event->Size < Event->Header.HeaderSize + sizeof (UINT32)) {
>   return EFI_INVALID_PARAMETER;
> }
>
> which ensures that the event size covers at least the EFI_TCG2_EVENT,
> which obviously implies that 'size' is expected to include it.
>

FWIW the same principle applies in the u-boot implementation as well.
As far as this series is concerned, keeping the
TCG_PCClientTaggedEvent will make reading the code & spec in parallel
easier, but I don't have any strong opinions -- I am fine with both

Cheers
/Ilias

> So please disregard this series

  reply	other threads:[~2024-03-08 10:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-08  8:57 [PATCH v3 0/5] efi/libstub: Fall back to CC proto for measurement Ard Biesheuvel
2024-03-08  8:57 ` [PATCH v3 1/5] efi/libstub: Use correct event size when measuring data into the TPM Ard Biesheuvel
2024-03-08  9:11   ` Ard Biesheuvel
2024-03-08  9:37   ` Ilias Apalodimas
2024-03-08  9:43     ` Ard Biesheuvel
2024-03-08 10:05       ` Ilias Apalodimas [this message]
2024-03-08  8:57 ` [PATCH v3 2/5] efi/tpm: Use symbolic GUID name from spec for final events table Ard Biesheuvel
2024-03-08  8:57 ` [PATCH v3 3/5] efi/libstub: Add Confidential Computing (CC) measurement typedefs Ard Biesheuvel
2024-03-08  8:57 ` [PATCH v3 4/5] efi/libstub: Measure into CC protocol if TCG2 protocol is absent Ard Biesheuvel
2024-03-08  8:58 ` [PATCH v3 5/5] efi/libstub: Add get_event_log() support for CC platforms Ard Biesheuvel

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=CAC_iWjL3yHt16vrwCh8V3FWqLRHJ07wt-pL2scB+2B8Y2AHgvg@mail.gmail.com \
    --to=ilias.apalodimas@linaro.org \
    --cc=ardb+git@google.com \
    --cc=ardb@kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=stable@vger.kernel.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).