From 75a2355a1945d3028a8aa77e8f55eaf5ddfb1214 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Tue, 4 May 2021 20:18:41 +0200 Subject: soc/amd/common/fsp/fsp-acpi: add check for maximum table size If the ACPI table size in the HOB data header is larger than the maximum HOB payload, don't add the table at all and print an error instead, since in this case the memcpy would read past the end of the HOB data structure. Signed-off-by: Felix Held Change-Id: I965c01bd9ab66b14d6f77b6f23c28479ae6d6a50 Reviewed-on: https://review.coreboot.org/c/coreboot/+/52897 Reviewed-by: Jason Glenesk Reviewed-by: Raul Rangel Reviewed-by: Marshall Dawson Tested-by: build bot (Jenkins) --- src/soc/amd/common/fsp/fsp-acpi.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/soc') diff --git a/src/soc/amd/common/fsp/fsp-acpi.c b/src/soc/amd/common/fsp/fsp-acpi.c index b530688c03..f92d571066 100644 --- a/src/soc/amd/common/fsp/fsp-acpi.c +++ b/src/soc/amd/common/fsp/fsp-acpi.c @@ -28,6 +28,12 @@ uintptr_t add_agesa_fsp_acpi_table(guid_t guid, const char *name, acpi_rsdp_t *r return current; } + if (data->table_size_in_bytes > sizeof(data->hob_payload)) { + printk(BIOS_ERR, "AGESA %s ACPI table size larger than maximum HOB payload " + "size.\n", name); + return current; + } + printk(BIOS_INFO, "ACPI: * %s (AGESA).\n", name); memcpy(table, data->hob_payload, data->table_size_in_bytes); -- cgit v1.2.3