linux-cxl.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dave Jiang" <dave.jiang@intel.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v6 03/13] ACPI: extlog: Validate elog record length before walking sections
Date: Fri, 04 Sep 2026 17:40:23 +0000	[thread overview]
Message-ID: <20260904174024.316C11F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904172337.1409775-4-dave.jiang@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing bounds check on firmware-supplied physical address allows out-of-bounds memory read (and potential kernel panic) when mapped to a virtual address.
--

commit 7d4af53bdefb9af34e8feff4c7e1e31654f51d71
Author: Dave Jiang <dave.jiang@intel.com>
Subject: ACPI: extlog: Validate elog record length before walking sections

This patch adds validation to extlog_print() to bound the length of elog
records and check them via cper_estatus_check() before walking the sections.
It drops malformed records to prevent out-of-bounds reads if data_length
extends past elog_buf.

Closes: https://sashiko.dev/#/patchset/20260714231835.303081-1-dave.jiang@intel.com?part=6

> diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
> index 7ad3b36013cc6..046e92ee195f9 100644
> --- a/drivers/acpi/acpi_extlog.c
> +++ b/drivers/acpi/acpi_extlog.c
> @@ -208,6 +208,15 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
>  
>  	tmp = (struct acpi_hest_generic_status *)elog_buf;
>  
> +	/*
> +	 * Bound the length before cper_estatus_check() walks the sections: it
> +	 * iterates over data_length, which is not yet known to fit elog_buf.
> +	 * cper_estatus_check_header() then rejects a length that wrapped, which
> +	 * the bound cannot see.
> +	 */
> +	if (cper_estatus_len(tmp) > ELOG_ENTRY_LEN || cper_estatus_check(tmp))
> +		return NOTIFY_DONE;
> +

[Severity: High]
This is a pre-existing issue, but since the goal of this code is to protect
against malformed firmware records, there appears to be a missing bounds
check earlier in this path.

In drivers/acpi/acpi_extlog.c:extlog_elog_entry_check():

    data = ELOG_ENTRY_DATA(idx);
    if ((data & ELOG_ENTRY_VALID) == 0)
        return NULL;

    data &= EXT_ELOG_ENTRY_MASK;
    estatus = (struct acpi_hest_generic_status *)ELOG_ENTRY_ADDR(data);

    /* if no valid data in elog entry, just return */
    if (estatus->block_status == 0)
        return NULL;

The physical address read from the firmware-controlled L1 directory into
data is converted to a virtual pointer via the ELOG_ENTRY_ADDR() macro. It
is then immediately dereferenced by estatus->block_status.

Is there anything verifying that this physical address falls within the
mapped elog_base to elog_base + elog_size boundaries?

If the resulting virtual address points to an unmapped page in the vmalloc
or ioremap region, could this dereference cause a kernel page fault and
panic?

>  	if (!ras_userspace_consumers()) {
>  		print_extlog_rcd(NULL, tmp, cpu);
>  		goto out;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904172337.1409775-1-dave.jiang@intel.com?part=3

  reply	other threads:[~2026-09-04 17:40 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 [this message]
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
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=20260904174024.316C11F00A3D@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;
as well as URLs for NNTP newsgroup(s).