[PATCH] efi_loader: Check for pointers before appending to the eventlog
Ilias Apalodimas
ilias.apalodimas at linaro.org
Tue Nov 23 17:24:24 CET 2021
The TCG protocol returns EFI_SUCCESS even when it fails to install.
If the protocol is not installed there should be no calls to
tcg2_agile_log_append(). However there are calls to this function
occurring outside the TCG protocol invocation (e.g tcg2_measure_pe_image).
Let's deal with this and shield the code from crashing while complaining,
so buggy code can be spotted and fixed.
Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
---
Heinrich this is rebased on top of https://lore.kernel.org/u-boot/20211123115335.125252-1-ruchika.gupta@linaro.org/
lib/efi_loader/efi_tcg2.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index 133fe8291a92..57a1f37695f6 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -311,6 +311,17 @@ static efi_status_t tcg2_agile_log_append(u32 pcr_index, u32 event_type,
struct efi_tcg2_final_events_table *final_event;
efi_status_t ret = EFI_SUCCESS;
+ /*
+ * This should never happen. This function should only be invoked if
+ * the TCG2 protocol has been installed. However since we always
+ * return EFI_SUCCESS from efi_tcg2_register shield callers against
+ * crashing and complain
+ */
+ if (!event_log.final_buffer || !event_log.buffer) {
+ log_err("EFI TCG2 protocol not installed\n");
+ return EFI_INVALID_PARAMETER;
+ }
+
/* if ExitBootServices hasn't been called update the normal log */
if (!event_log.ebs_called) {
if (event_log.truncated ||
--
2.34.0
More information about the U-Boot
mailing list