Re: [RFC] efi/tpm: add efi.tpm_log as a reserved region in 820_table_firmware

From: Breno Leitao
Date: Thu Sep 12 2024 - 09:04:41 EST


Hello Ard,

On Thu, Sep 12, 2024 at 12:51:57PM +0200, Ard Biesheuvel wrote:
> I don't see how this could be an EFI bug, given that it does not deal
> with E820 tables at all.

I want to back up a little bit and make sure I am following the
discussion.

>From what I understand from previous discussion, we have an EFI bug as
the root cause of this issue.

This happens because the EFI does NOT mark the EFI TPM event log memory
region as reserved (EFI_RESERVED_TYPE). Not having an entry for the
event table memory in EFI memory mapped, then libstub will ignore it
completely (the TPM event log memory range) and not populate e820 table
with it.

Once the e820 table does not have the memory range for TPM event log,
then the kernel is free to overwrite that memory region, causing
corruptions all across the board.

>From what I understand from the thread discussion, there are three ways
to "solve" it:

1) Fix the EFI to pass the TPM event log memory as reserved.

2) Workaround it in libstub, and considering the TPM event log memory
range when populating the e820 table. (As proposed in
https://lore.kernel.org/all/2542182d-aa79-4705-91b6-fa593bacffa6@xxxxxxxxx/)

3) Workaround in later in the kernel, as proposed in
https://lore.kernel.org/all/20240911104109.1831501-1-usamaarif642@xxxxxxxxx/

Please let me know if my understanding is flawed here.

Thank you!
--breno