public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efistub/tpm: Use ACPI reclaim memory for event log to avoid corruption
@ 2024-09-12 15:52 Ard Biesheuvel
  2024-09-13  6:27 ` Ilias Apalodimas
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Ard Biesheuvel @ 2024-09-12 15:52 UTC (permalink / raw)
  To: linux-efi; +Cc: Ard Biesheuvel, stable, Breno Leitao, Usama Arif

From: Ard Biesheuvel <ardb@kernel.org>

The TPM event log table is a Linux specific construct, where the data
produced by the GetEventLog() boot service is cached in memory, and
passed on to the OS using a EFI configuration table.

The use of EFI_LOADER_DATA here results in the region being left
unreserved in the E820 memory map constructed by the EFI stub, and this
is the memory description that is passed on to the incoming kernel by
kexec, which is therefore unaware that the region should be reserved.

Even though the utility of the TPM2 event log after a kexec is
questionable, any corruption might send the parsing code off into the
weeds and crash the kernel. So let's use EFI_ACPI_RECLAIM_MEMORY
instead, which is always treated as reserved by the E820 conversion
logic.

Cc: <stable@vger.kernel.org>
Reported-by: Breno Leitao <leitao@debian.org>
Tested-by: Usama Arif <usamaarif642@gmail.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 drivers/firmware/efi/libstub/tpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c
index df3182f2e63a..1fd6823248ab 100644
--- a/drivers/firmware/efi/libstub/tpm.c
+++ b/drivers/firmware/efi/libstub/tpm.c
@@ -96,7 +96,7 @@ static void efi_retrieve_tcg2_eventlog(int version, efi_physical_addr_t log_loca
 	}
 
 	/* Allocate space for the logs and copy them. */
-	status = efi_bs_call(allocate_pool, EFI_LOADER_DATA,
+	status = efi_bs_call(allocate_pool, EFI_ACPI_RECLAIM_MEMORY,
 			     sizeof(*log_tbl) + log_size, (void **)&log_tbl);
 
 	if (status != EFI_SUCCESS) {
-- 
2.46.0.662.g92d0881bb0-goog


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2024-10-31  9:04 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-12 15:52 [PATCH] efistub/tpm: Use ACPI reclaim memory for event log to avoid corruption Ard Biesheuvel
2024-09-13  6:27 ` Ilias Apalodimas
2024-09-13 10:00 ` Breno Leitao
2024-10-24 16:20 ` Jiri Slaby
2024-10-25  5:07   ` Jiri Slaby
2024-10-25  5:09     ` Jiri Slaby
2024-10-25  7:30       ` Ard Biesheuvel
2024-10-30 16:32         ` Gregory Price
2024-10-31  7:55         ` Jiri Slaby
2024-10-31  9:04           ` Ard Biesheuvel
2024-10-25 13:27       ` Usama Arif
2024-10-30  5:25         ` Jiri Slaby
2024-10-30 17:13           ` Usama Arif
2024-10-30 18:02             ` Gregory Price
2024-10-30 18:24               ` Usama Arif
2024-10-31  8:38                 ` Jiri Slaby
2024-10-30 18:26             ` Gregory Price
2024-10-30 19:43               ` Ard Biesheuvel
2024-10-30 20:30                 ` Gregory Price
2024-10-31  8:19               ` Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox