From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EF3B400964; Fri, 17 Jul 2026 16:16:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784305019; cv=none; b=uZuenjS1lqBhMHTbDiWi7iSukCsUwX8sM8u6L6eca4gtWl/7efMIrHlrZMPqtxAbESj9ptDqPnqyxK//V0QEhahF8rX3+2Xf56tPD7XgBqYhoQ0QYxrBFbur6oBu0ZX5A0y8lsbfqiUwekQ/1nrdU3w3w1dmwyxXkM0aeN8NOro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784305019; c=relaxed/simple; bh=jYqwb5/XYCZgXZWwzJPvgI2RvRqPJgSbbtjaTErOHOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m/kg4CyMMzCRAVF8dNwNegwSo/cXXRyyuskaFvLdLZ1Oq8/vB6bkpWrIPARgUXt7LoqQ17O++M5IiLxZs0VDW3dIEJV/A7Gqrb6HCUx+wmjXjkmQcN9Kthh+BzZGVJzWEksRm4MS2UlnXN4CJUL0udcxwI4PbZrljTY827rbxrw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E35221F00A3A; Fri, 17 Jul 2026 16:16:56 +0000 (UTC) From: Dave Jiang To: linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org Cc: rafael@kernel.org, tony.luck@intel.com, bp@alien8.de, guohanjun@huawei.com, mchehab@kernel.org, xueshuai@linux.alibaba.com, terry.bowman@amd.com, sashiko-bot@kernel.org Subject: [PATCH v3 05/10] ACPI: extlog: Validate PCIe error section length before payload access Date: Fri, 17 Jul 2026 09:16:42 -0700 Message-ID: <20260717161647.1493259-6-dave.jiang@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260717161647.1493259-1-dave.jiang@intel.com> References: <20260717161647.1493259-1-dave.jiang@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit sashiko-bot flagged the missing section-length check before extlog_print_pcie() touches the PCIe payload. extlog_print_pcie() reads pcie_err->validation_bits and device_id and copies the 96-byte aer_info buffer without checking that gdata->error_data_length is large enough for a struct cper_sec_pcie. cper_estatus_check() keeps the read within the estatus block, but a short section still lets stale adjacent bytes be treated as PCIe error data. Reject a section too small to hold the record before touching any field. Reported-by: sashiko-bot@kernel.org Fixes: e778ffefa34d ("ACPI: extlog: Trace CPER PCI Express Error Section") Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Dave Jiang --- drivers/acpi/acpi_extlog.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c index fbc88c584c06..0c440d75d9a7 100644 --- a/drivers/acpi/acpi_extlog.c +++ b/drivers/acpi/acpi_extlog.c @@ -134,7 +134,7 @@ static int print_extlog_rcd(const char *pfx, } static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, - int severity) + int severity, u32 len) { #ifdef ACPI_APEI_PCIEAER struct aer_capability_regs aer_regs = {}; @@ -145,6 +145,9 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, int aer_severity; int domain; + if (len < sizeof(*pcie_err)) + return; + if (!(pcie_err->validation_bits & CPER_PCIE_VALID_DEVICE_ID && pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO)) return; @@ -247,7 +250,8 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, } else if (guid_equal(sec_type, &CPER_SEC_PCIE)) { struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata); - extlog_print_pcie(pcie_err, gdata->error_severity); + extlog_print_pcie(pcie_err, gdata->error_severity, + gdata->error_data_length); } else { void *err = acpi_hest_get_payload(gdata); -- 2.55.0