On Thu, 7 Mar 2024 at 12:13, Ard Biesheuvel <ardb@xxxxxxxxxx> wrote: > > On Thu, 7 Mar 2024 at 12:08, Ard Biesheuvel <ardb@xxxxxxxxxx> wrote: > > > > Hi Muhammad, > > > > Thanks for the report. > > > > On Thu, 7 Mar 2024 at 12:02, Muhammad Usama Anjum > > <usama.anjum@xxxxxxxxxxxxx> wrote: > > > > > > Hi, > > > > > > The recent patch: > > > 276805fb9c305: efi/libstub: Add get_event_log() support for CC platforms > > > has introduced > > > #define EFI_CC_EVENT_LOG_FORMAT_TCG_2 0x00000002 > > > > > > But EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 has the same numerical value: > > > #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x2 > > > > > > Thus there is dead code in efi_retrieve_tcg2_eventlog() i.e, multiple if > > > conditions with (version == 2) I'm unable to decide on what is wrong and > > > what is right here. Please have a look. > > > > > > > Why is this a problem? The compiler will recognize this and simplify > > the conditional. The code as written is semantically correct, the fact > > that the symbolic constants resolve to the same numerical value is > > just an implementation detail. > > Ah hold on. I see what you mean now: > > if (version == EFI_TCG2_EVENT_LOG_FORMAT_TCG_2) > final_events_table = get_efi_config_table(LINUX_EFI_TPM_FINAL_LOG_GUID); > + else if (version == EFI_CC_EVENT_LOG_FORMAT_TCG_2) > + final_events_table = get_efi_config_table(LINUX_EFI_CC_FINAL_LOG_GUID); > > Yes, that is broken. Could we fix it like this perhaps? --- a/drivers/firmware/efi/libstub/tpm.c +++ b/drivers/firmware/efi/libstub/tpm.c @@ -75,8 +75,7 @@ * * CC Event log also uses TCG2 format, handle it same as TPM2. */ if (version > EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2) { /* * The TCG2 log format has variable length entries, * and the information to decode the hash algorithms @@ -109,10 +108,11 @@ * Figure out whether any events have already been logged to the * final events structure, and if so how much space they take up */ if (version > EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2) final_events_table = get_efi_config_table(LINUX_EFI_TPM_FINAL_LOG_GUID) ?: get_efi_config_table(LINUX_EFI_CC_FINAL_LOG_GUID);