Re: [PATCH] tpm: efi: Don't create binary_bios_measurements file for an empty log
From: Kai-Heng Feng
Date: Fri Oct 30 2020 - 03:00:59 EST
> On Oct 29, 2020, at 01:39, Tyler Hicks <tyhicks@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On 2020-10-28 11:30:11, Tyler Hicks wrote:
>> So, we need help from Kai, Kenneth, or Mimi to verify my assumption that
>> their firmware is providing an empty main event log and a populated
>> final event log.
>
> Hi Kai, Kenneth, and Mimi - could one or two of you please follow these
> steps:
>
> 1) Apply the proposed patch in the grandparent of this email so that
> your kernel doesn't crash
> 2) Revert commit 7f3d176f5f7e ("tpm: Require that all digests are
> present in TCG_PCR_EVENT2 structures") so that
> __calc_tpm2_event_size() goes back to being less picky and may treat
> a final log event as a valid event log header
> 3) Add some debugging warnings in efi_tpm_eventlog_init() to check for
> an empty main event log and a populated final event log, as shown
> below
> 4) Boot the resulting kernel build, look for the warnings, and report
> back
>
> diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
> index c1955d320fec..c4d2dbd5ed42 100644
> --- a/drivers/firmware/efi/tpm.c
> +++ b/drivers/firmware/efi/tpm.c
> @@ -78,6 +78,9 @@ int __init efi_tpm_eventlog_init(void)
> goto out;
> }
>
> + WARN(!log_tbl->size && final_tbl->nr_events,
> + "nr_events = %llu\n", final_tbl->nr_events);
> +
> tbl_size = 0;
> if (final_tbl->nr_events != 0) {
> void *events = (void *)efi.tpm_final_log
> @@ -95,6 +98,8 @@ int __init efi_tpm_eventlog_init(void)
> goto out_calc;
> }
>
> + WARN(!log_tbl->size && tbl_size, "tbl_size = %d\n", tbl_size);
> +
> memblock_reserve((unsigned long)final_tbl,
> tbl_size + sizeof(*final_tbl));
> efi_tpm_final_log_size = tbl_size;
>
> For your convenience, I've created a branch with these changes on top of
> v5.9:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/linux.git/log/?h=tpm/bin-bios-measurements-debug
Dmesg attached.
Kai-Heng
Attachment:
dmesg
Description: Binary data
>
> Thank you!
>
> Tyler