From: sashiko-bot@kernel.org
To: "Dave Jiang" <dave.jiang@intel.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v6 11/13] ACPI: APEI: GHES: Validate memory error section length before payload access
Date: Fri, 04 Sep 2026 18:12:10 +0000 [thread overview]
Message-ID: <20260904181210.E154F1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904172337.1409775-12-dave.jiang@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The patch fixes length validation in ghes_do_proc() but leaves an identical logic flaw and buffer over-read unfixed in cper_print_mem().
--
commit 8bbaca1beceadb4f3349da69c4f0bedd1d913c54
Author: Dave Jiang <dave.jiang@intel.com>
Subject: ACPI: APEI: GHES: Validate memory error section length before payload access
This patch adds length validation in ghes_do_proc() before accessing the
CPER_SEC_PLATFORM_MEM payload to prevent reading past the record. It ensures
records are at least 73 bytes and validates the remaining length based on the
claimed fields.
Closes: https://sashiko.dev/#/patchset/20260714231835.303081-1-dave.jiang@intel.com?part=7
> diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
> index 111895c57c2f9..2077cc90569a0 100644
> --- a/drivers/acpi/apei/ghes.c
> +++ b/drivers/acpi/apei/ghes.c
[ ... ]
> @@ -954,6 +976,25 @@ static void ghes_do_proc(struct ghes *ghes,
> if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
> struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata);
>
> + /*
> + * Check once for all three consumers below. The 73-byte
> + * UEFI 2.1/2.2 layout is the floor, matching
> + * cper_estatus_print_section() and making
> + * validation_bits safe to read.
> + */
> + if (gdata->error_data_length <
> + sizeof(struct cper_sec_mem_err_old))
> + continue;
> +
[Severity: High]
This isn't a bug introduced by this patch, but does leaving cper_print_mem()
unfixed bypass these newly added safety checks?
As noted in the commit message, cper_print_mem() gets the mask checking
wrong. When firmware provides a CPER memory error record with a length
between 74 and 79 bytes, the exact match check in cper_print_mem() fails to
catch the invalid length:
drivers/firmware/efi/cper.c:cper_print_mem() {
...
/* Don't trust UEFI 2.1/2.2 structure with bad validation bits */
if (len == sizeof(struct cper_sec_mem_err_old) &&
(mem->validation_bits & ~(CPER_MEM_VALID_RANK_NUMBER - 1))) {
pr_err(FW_WARN "valid bits set for fields beyond structure\n");
return;
}
...
}
Because ghes_proc() calls ghes_print_estatus() before ghes_do_proc(), this
code executes before the new checks in this patch are reached.
When cper_print_mem() then calls cper_mem_err_pack(), it blindly reads
out-of-bounds fields if the payload is smaller than 80 bytes:
drivers/firmware/efi/cper.c:cper_mem_err_pack() {
...
if (mem->validation_bits & CPER_MEM_VALID_MODULE_HANDLE)
cmem->mem_dev_handle = mem->mem_dev_handle;
...
}
Could this result in an out-of-bounds memory read (such as mem_dev_handle
at offset 78) and an information leak to dmesg before ghes_do_proc() has a
chance to reject the malformed record?
> + /* Then require what the claimed fields actually need. */
> + if (gdata->error_data_length <
> + ghes_mem_err_min_len(mem_err->validation_bits)) {
> + pr_warn_ratelimited(FW_WARN GHES_PFX
> + "memory error section too small (%u) for the fields it claims\n",
> + gdata->error_data_length);
> + continue;
> + }
> +
> atomic_notifier_call_chain(&ghes_report_chain, sev, mem_err);
>
> arch_apei_report_mem_error(sev, mem_err);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260904172337.1409775-1-dave.jiang@intel.com?part=11
next prev parent reply other threads:[~2026-09-04 18:12 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 17:23 [PATCH v6 00/13] ACPI: APEI: GHES: Collection of fixes for issues reported by sashiko Dave Jiang
2026-09-04 17:23 ` [PATCH v6 01/13] efi/cper: Reject CPER records with an out-of-range error_data_length Dave Jiang
2026-09-04 17:39 ` sashiko-bot
2026-09-04 17:23 ` [PATCH v6 02/13] efi/cper: Reject an error status block length that wraps a u32 Dave Jiang
2026-09-04 17:38 ` sashiko-bot
2026-09-04 17:23 ` [PATCH v6 03/13] ACPI: extlog: Validate elog record length before walking sections Dave Jiang
2026-09-04 17:40 ` sashiko-bot
2026-09-04 17:23 ` [PATCH v6 04/13] ACPI: extlog: Defer CXL protocol error handling to avoid lock inversion Dave Jiang
2026-09-04 17:23 ` [PATCH v6 05/13] ACPI: extlog: Avoid populating software AER metadata from raw hardware buffer Dave Jiang
2026-09-04 17:58 ` sashiko-bot
2026-09-04 17:23 ` [PATCH v6 06/13] ACPI: extlog: Validate PCIe error section length before payload access Dave Jiang
2026-09-04 17:23 ` [PATCH v6 07/13] ACPI: extlog: Fix CONFIG_ACPI_APEI_PCIEAER guard typo Dave Jiang
2026-09-04 17:23 ` [PATCH v6 08/13] ACPI: APEI: GHES: Bound CXL event record copy to the firmware section length Dave Jiang
2026-09-04 17:23 ` [PATCH v6 09/13] ACPI: APEI: GHES: Validate CXL protocol error section length before RAS cap copy Dave Jiang
2026-09-04 18:05 ` sashiko-bot
2026-09-04 17:23 ` [PATCH v6 10/13] efi/cper: Read only validated fields in cper_mem_err_pack() Dave Jiang
2026-09-04 18:09 ` sashiko-bot
2026-09-04 17:23 ` [PATCH v6 11/13] ACPI: APEI: GHES: Validate memory error section length before payload access Dave Jiang
2026-09-04 18:12 ` sashiko-bot [this message]
2026-09-04 17:23 ` [PATCH v6 12/13] ACPI: APEI: GHES: Bound AER info copy and sanitize software metadata Dave Jiang
2026-09-04 18:08 ` sashiko-bot
2026-09-04 17:23 ` [PATCH v6 13/13] cxl/ras: Make cxl_cper_handle_prot_err() static Dave Jiang
2026-09-04 18:16 ` sashiko-bot
2026-09-04 18:21 ` [PATCH v6 00/13] ACPI: APEI: GHES: Collection of fixes for issues reported by sashiko Rafael J. Wysocki (Intel)
2026-09-04 19:44 ` Dave Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260904181210.E154F1F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dave.jiang@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox