Attention is currently required from: Arthur Heymans, Elyes Haouas, Sergii Dmytruk.
Martin L Roth has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/76787?usp=email )
Change subject: commonlib/bsd/tpm_log_defs.h: Use C99 flexible arrays ......................................................................
Patch Set 3:
(1 comment)
Patchset:
PS2:
`&tcpa_spec_entry. […]
The problem isn't with the tcpa_log_entry itself, it's the inclusion of that into tcpa_spec_entry.
To fix this without changing anything else, we can create an additional structure:
``` #define TCPA_LOG_DIGEST_LENGTH 20 struct tcpa_log_entry_header { uint32_t pcr; uint32_t event_type; uint8_t digest[TCPA_LOG_DIGEST_LENGTH]; uint32_t event_data_size; } __packed;
struct tcpa_log_entry { uint32_t pcr; uint32_t event_type; uint8_t digest[TCPA_LOG_DIGEST_LENGTH]; uint32_t event_data_size; uint8_t event[0]; } __packed;
struct tcpa_spec_entry { struct tcpa_log_entry_header entry; uint8_t signature[16]; uint32_t platform_class; uint8_t spec_version_minor; uint8_t spec_version_major; uint8_t spec_errata; uint8_t reserved; uint8_t vendor_info_size; uint8_t vendor_info[0]; } __packed; ```
I'm not crazy about the duplicated code here, but unless we want to do the ugly conversion in the one location in util/cbmem that `->event` is used the duplicated code is probably the next best alternative to get rid of that array. Using the ugly conversion means that this:
``` if (len != 0) { current += len; printf("\tEvent data: "); if (can_print(log_entry->event, len)) printf("%.*s\n", len, log_entry->event); else print_hex_line(log_entry->event, len); } else { printf("\tEvent data not provided\n"); } ``` Becomes this:
``` if (len != 0) { uint8_t *ptr = (uint8_t *)log_entry + sizeof(*log_entry); current += len; printf("\tEvent data: "); if (can_print(ptr, len)) printf("%.*s\n", len, ptr); else print_hex_line(ptr, len); } else { printf("\tEvent data not provided\n"); } ```
Personally, I could live with that ugly change.