[PATCH v8 12/22] efi/cper: validate the remaining length before reading a section

From: Ahmed Tiba

Date: Thu Dec 03 2026 - 08:42:43 EST


cper_estatus_check() enters the section loop whenever any data remains.
When a malformed status block leaves fewer than sizeof(*gdata) trailing
bytes, acpi_hest_get_size() reads gdata->revision beyond the valid buffer
before the existing record-size check can reject it.

Require a complete generic data header before dereferencing the section.

Fixes: c4335fdd3822 ("ACPI: APEI: fix the wrong iteration of generic error status block")
Reported-by: sashiko-bot@xxxxxxxxxx
Link: https://sashiko.dev/#/message/20260708143557.91D601F000E9%40smtp.kernel.org
Signed-off-by: Ahmed Tiba <ahmed.tiba@xxxxxxx>
---
drivers/firmware/efi/cper.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
index 13b3e72c3b62..118953d41cc2 100644
--- a/drivers/firmware/efi/cper.c
+++ b/drivers/firmware/efi/cper.c
@@ -793,6 +793,9 @@ int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
apei_estatus_for_each_section(estatus, gdata) {
int record_size;

+ if (data_len < sizeof(*gdata))
+ return -EINVAL;
+
/*
* The <acpi/ghes.h> helpers sum these as a signed int, so a
* huge error_data_length wraps small rather than large and the

--
2.43.0