From c3bd5d1b369ab24972240d20b3b1b67305543ede Mon Sep 17 00:00:00 2001 From: Dennis Chen Date: Wed, 8 Nov 2017 09:13:00 +0000 Subject: [PATCH 1/3] Prototype fixing for (*hash_log_extend_event) According to the section 6.6.1 'Prototype' in 'TCG EFI Protocol Spec', the 3rd parameter of the (*hash_log_extend_event) should be 'EFI_PHYSICAL_ADDRESS' which is 'grub_efi_physical_address_t' in the real implementation. So this patch drop the pointer mark '*' from this prototype. Signed-off-by: Dennis Chen --- include/grub/efi/tpm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/efi/tpm.h b/include/grub/efi/tpm.h index e2aff4a3c..63d8a0fe7 100644 --- a/include/grub/efi/tpm.h +++ b/include/grub/efi/tpm.h @@ -129,7 +129,7 @@ struct grub_efi_tpm2_protocol grub_efi_boolean_t *EventLogTruncated); grub_efi_status_t (*hash_log_extend_event) (struct grub_efi_tpm2_protocol *this, grub_efi_uint64_t Flags, - grub_efi_physical_address_t *DataToHash, + grub_efi_physical_address_t DataToHash, grub_efi_uint64_t DataToHashLen, EFI_TCG2_EVENT *EfiTcgEvent); grub_efi_status_t (*submit_command) (struct grub_efi_tpm2_protocol *this, From 7cf67f22fdb1b8ab711c9cf43b7135b2e1435c22 Mon Sep 17 00:00:00 2001 From: Dennis Chen Date: Wed, 8 Nov 2017 09:28:49 +0000 Subject: [PATCH 2/3] Fix the build issue in TPM module The original code use deprecated 'Event' data structure with the wrong member variable names, which result in the build error. This patch fix it by using 'TCG_PCR_EVENT'. Signed-off-by: Dennis Chen --- grub-core/kern/efi/tpm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/grub-core/kern/efi/tpm.c b/grub-core/kern/efi/tpm.c index c9fb3c133..7af07ddb5 100644 --- a/grub-core/kern/efi/tpm.c +++ b/grub-core/kern/efi/tpm.c @@ -175,7 +175,7 @@ grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, grub_size_t size, grub_uint8_t pcr, const char *description) { - Event *event; + TCG_PCR_EVENT *event; grub_efi_status_t status; grub_efi_tpm_protocol_t *tpm; grub_efi_physical_address_t lastevent; @@ -188,18 +188,18 @@ grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, if (!grub_tpm_present(tpm)) return 0; - event = grub_zalloc(sizeof (Event) + grub_strlen(description) + 1); + event = grub_zalloc(sizeof (TCG_PCR_EVENT) + grub_strlen(description) + 1); if (!event) return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate TPM event buffer")); - event->pcrindex = pcr; - event->eventtype = EV_IPL; - event->eventsize = grub_strlen(description) + 1; - grub_memcpy(event->event, description, event->eventsize); + event->PCRIndex = pcr; + event->EventType = EV_IPL; + event->EventSize = grub_strlen(description) + 1; + grub_memcpy(event->Event, description, event->EventSize); algorithm = TCG_ALG_SHA; - status = efi_call_7 (tpm->log_extend_event, tpm, buf, (grub_uint64_t) size, + status = efi_call_7 (tpm->log_extend_event, tpm, (grub_efi_physical_address_t)buf, (grub_uint64_t) size, algorithm, event, &eventnum, &lastevent); switch (status) { @@ -245,7 +245,7 @@ grub_tpm2_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, event->Size = sizeof(*event) - sizeof(event->Event) + grub_strlen(description) + 1; grub_memcpy(event->Event, description, grub_strlen(description) + 1); - status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, buf, + status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (grub_efi_physical_address_t)buf, (grub_uint64_t) size, event); switch (status) { From 63818e780004c5bebc51b1319ab216d14019c83e Mon Sep 17 00:00:00 2001 From: Dennis Chen Date: Wed, 8 Nov 2017 09:45:39 +0000 Subject: [PATCH 3/3] Remove the deprecated 'Event' struct 'Event' struct will be not used any more, instead we use the 'TCG_PCR_EVENT', so this patch remove the older 'Event' data struct. Signed-off-by: Dennis Chen --- grub-core/kern/efi/tpm.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/grub-core/kern/efi/tpm.c b/grub-core/kern/efi/tpm.c index 7af07ddb5..532e534e4 100644 --- a/grub-core/kern/efi/tpm.c +++ b/grub-core/kern/efi/tpm.c @@ -161,15 +161,6 @@ grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, } } -typedef struct { - grub_uint32_t pcrindex; - grub_uint32_t eventtype; - grub_uint8_t digest[20]; - grub_uint32_t eventsize; - grub_uint8_t event[1]; -} Event; - - static grub_err_t grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, grub_size_t size, grub_uint8_t pcr,