Linux CXL
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v5 05/13] ACPI: extlog: Avoid populating software AER metadata from raw hardware buffer
Date: Thu, 27 Aug 2026 16:06:00 -0700	[thread overview]
Message-ID: <58b33ede-e679-4251-bbc6-3af30c8edcbe@intel.com> (raw)
In-Reply-To: <20260827205837.468361F000E9@smtp.kernel.org>



On 8/27/26 1:58 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> 
> New issues:
> - [Medium] Data loss of TLP Prefix Log / Extended Flit Log due to arbitrary payload truncation.

Yup. Will fix in v6.

DJ

> 
> Pre-existing issues:
> - [High] Out-of-bounds MMIO read and stack array bounds poisoning in `cxl_rch_get_aer_info()`.
> --
> 
> commit 99282f77735a9b69f6cccf74ca39147b80930bf8
> Author: Dave Jiang <dave.jiang@intel.com>
> ACPI: extlog: Avoid populating software AER metadata from raw hardware buffer
> 
> This commit addresses an issue in extlog_print_pcie() where casting the raw
> CPER aer_info buffer to a software struct populates software-only fields
> with raw hardware bytes. It copies only the leading registers and the
> Header Log DWORDs into a zeroed local struct to prevent out-of-bounds loop
> reads.
> 
> Link: https://lore.kernel.org/linux-cxl/20260709165457.8BA181F000E9@smtp.kernel.org/
> 
>> diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
>> --- a/drivers/acpi/acpi_extlog.c
>> +++ b/drivers/acpi/acpi_extlog.c
> [ ... ]
>> @@ -149,7 +149,17 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
>>  		return;
>>  
>>  	aer_severity = cper_severity_to_aer(severity);
>> -	aer = (struct aer_capability_regs *)pcie_err->aer_info;
>> +
>> +	/*
>> +	 * struct pcie_tlp_log is larger than the hardware layout, so only the
>> +	 * leading registers and the four Header Log DWORDs of aer_info map onto
>> +	 * the struct. Copy that much and leave the rest zero, which covers the
>> +	 * software-only header_len and flit.
>> +	 */
>> +	memcpy(&aer_regs, pcie_err->aer_info,
>> +	       offsetof(struct aer_capability_regs, header_log) +
>> +	       PCIE_STD_NUM_TLP_HEADERLOG * sizeof(u32));
> 
> [Severity: Medium]
> Will this truncated copy result in the permanent loss of the TLP Prefix Log?
> 
> The CPER aer_info array contains a raw 96-byte snapshot of the hardware AER
> capability, with the TLP Prefix Log located at offset 0x38 (56 bytes). By
> truncating the memcpy to 44 bytes, the remainder of the CPER payload is
> ignored, which silently drops the hardware-provided TLP Prefix Logs or
> Extended Flit Logs during PCIe error handling.
> 
> Would it be better to explicitly extract the prefix log from offset 56 in
> the CPER record into aer_regs.header_log.prefix to avoid data loss?
> 
> [ ... ]
> 
> This isn't a bug introduced by this patch, but I noticed a similar 
> pre-existing AER software struct issue in drivers/cxl/core/ras_rch.c.
> 
> drivers/cxl/core/ras_rch.c:cxl_rch_get_aer_info()
>> 	int read_cnt = sizeof(struct aer_capability_regs) / sizeof(u32);
>> 	u32 *aer_regs_buf = (u32 *)aer_regs;
>> 	int n;
>> ...
>> 	for (n = 0; n < read_cnt; n++)
>> 		aer_regs_buf[n] = readl(aer_base + n * sizeof(u32));
> 
> [Severity: High]
> Does this loop perform an out-of-bounds MMIO read by using the size of the
> software structure?
> 
> Using sizeof(struct aer_capability_regs) (104 bytes) instead of the actual
> hardware capability size directly maps MMIO data into software fields
> (header_len and flit at offset 84). Later, when pcie_print_tlp_log() runs,
> it uses the MMIO-poisoned header_len (which can be up to 255) as a loop
> bound over the 14-element stack array log->dw[]. This leads to a massive
> out-of-bounds stack read that can log arbitrary stack memory.
> 
> Additionally, in the same file:
> 
> drivers/cxl/core/ras_rch.c:cxl_rch_get_aer_severity()
>> 		if (aer_regs->uncor_status & PCI_ERR_ROOT_FATAL_RCV)
>> 			*severity = AER_FATAL;
> 
> [Severity: High]
> Does this code misinterpret the flow control protocol error bit?
> 
> It tests the Root Error Status flag PCI_ERR_ROOT_FATAL_RCV (0x40) against
> the uncor_status register. In the uncor_status register context, 0x40
> actually represents PCI_ERR_UNC_FCP, meaning the severity is incorrectly
> computed.
> 


  reply	other threads:[~2026-08-27 23:06 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 20:37 [PATCH v5 00/13] ACPI: APEI: GHES: Collection of fixes for issues reported by sashiko Dave Jiang
2026-08-27 20:37 ` [PATCH v5 01/13] efi/cper: Reject CPER records with an out-of-range error_data_length Dave Jiang
2026-08-27 20:52   ` sashiko-bot
2026-08-27 20:37 ` [PATCH v5 02/13] efi/cper: Reject an error status block length that wraps a u32 Dave Jiang
2026-08-27 20:52   ` sashiko-bot
2026-08-27 20:37 ` [PATCH v5 03/13] ACPI: extlog: Validate elog record length before walking sections Dave Jiang
2026-08-27 20:55   ` sashiko-bot
2026-08-27 20:37 ` [PATCH v5 04/13] ACPI: extlog: Defer CXL protocol error handling to avoid lock inversion Dave Jiang
2026-08-27 20:55   ` sashiko-bot
2026-08-27 20:37 ` [PATCH v5 05/13] ACPI: extlog: Avoid populating software AER metadata from raw hardware buffer Dave Jiang
2026-08-27 20:58   ` sashiko-bot
2026-08-27 23:06     ` Dave Jiang [this message]
2026-08-27 20:37 ` [PATCH v5 06/13] ACPI: extlog: Validate PCIe error section length before payload access Dave Jiang
2026-08-27 20:37 ` [PATCH v5 07/13] ACPI: extlog: Fix CONFIG_ACPI_APEI_PCIEAER guard typo Dave Jiang
2026-08-27 20:37 ` [PATCH v5 08/13] ACPI: APEI: GHES: Bound CXL event record copy to the firmware section length Dave Jiang
2026-08-27 20:55   ` sashiko-bot
2026-08-27 20:37 ` [PATCH v5 09/13] ACPI: APEI: GHES: Validate CXL protocol error section length before RAS cap copy Dave Jiang
2026-08-27 20:53   ` sashiko-bot
2026-08-27 20:37 ` [PATCH v5 10/13] efi/cper: Read only validated fields in cper_mem_err_pack() Dave Jiang
2026-08-27 20:55   ` sashiko-bot
2026-08-27 20:37 ` [PATCH v5 11/13] ACPI: APEI: GHES: Validate memory error section length before payload access Dave Jiang
2026-08-27 21:05   ` sashiko-bot
2026-08-27 20:37 ` [PATCH v5 12/13] ACPI: APEI: GHES: Bound AER info copy and sanitize software metadata Dave Jiang
2026-08-27 21:01   ` sashiko-bot
2026-08-27 20:37 ` [PATCH v5 13/13] cxl/ras: Make cxl_cper_handle_prot_err() static Dave Jiang
2026-08-27 20:59   ` sashiko-bot

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=58b33ede-e679-4251-bbc6-3af30c8edcbe@intel.com \
    --to=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