From 571bfc95a662dda966fb236bd95c0c1dbc7e29cc Mon Sep 17 00:00:00 2001 From: Tamas K Lengyel Date: Wed, 8 Nov 2017 15:44:56 -0700 Subject: [PATCH] Fall-back TPM2 measurement if it fails with PE_COFF_IMAGE flag Signed-off-by: Tamas K Lengyel --- tpm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tpm.c b/tpm.c index dbbafbf..43e53c1 100644 --- a/tpm.c +++ b/tpm.c @@ -195,12 +195,15 @@ static EFI_STATUS tpm_log_event_raw(EFI_PHYSICAL_ADDRESS buf, UINTN size, CopyMem(event->Event, (VOID *)log, logsize); if (hash) { /* TPM 2 systems will generate the appropriate hash - themselves if we pass PE_COFF_IMAGE + themselves if we pass PE_COFF_IMAGE. In case that + fails we fall back to measuring without it. */ status = uefi_call_wrapper(tpm2->hash_log_extend_event, 5, tpm2, PE_COFF_IMAGE, buf, (UINT64) size, event); - } else { + } + + if (!hash || EFI_ERROR(status)) { status = uefi_call_wrapper(tpm2->hash_log_extend_event, 5, tpm2, 0, buf, (UINT64) size, event);