From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Ahmed Salem <x0rw3ll@gmail.com>,
"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
Sasha Levin <sashal@kernel.org>,
rafael@kernel.org, robert.moore@intel.com,
linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 5.10 30/34] ACPICA: Avoid sequence overread in call to strncmp()
Date: Sun, 1 Jun 2025 19:43:54 -0400 [thread overview]
Message-ID: <20250601234359.3518595-30-sashal@kernel.org> (raw)
In-Reply-To: <20250601234359.3518595-1-sashal@kernel.org>
From: Ahmed Salem <x0rw3ll@gmail.com>
[ Upstream commit 64b9dfd0776e9c38d733094859a09f13282ce6f8 ]
ACPICA commit 8b83a8d88dfec59ea147fad35fc6deea8859c58c
ap_get_table_length() checks if tables are valid by
calling ap_is_valid_header(). The latter then calls
ACPI_VALIDATE_RSDP_SIG(Table->Signature).
ap_is_valid_header() accepts struct acpi_table_header as an argument, so
the signature size is always fixed to 4 bytes.
The problem is when the string comparison is between ACPI-defined table
signature and ACPI_SIG_RSDP. Common ACPI table header specifies the
Signature field to be 4 bytes long[1], with the exception of the RSDP
structure whose signature is 8 bytes long "RSD PTR " (including the
trailing blank character)[2]. Calling strncmp(sig, rsdp_sig, 8) would
then result in a sequence overread[3] as sig would be smaller (4 bytes)
than the specified bound (8 bytes).
As a workaround, pass the bound conditionally based on the size of the
signature being passed.
Link: https://uefi.org/specs/ACPI/6.5_A/05_ACPI_Software_Programming_Model.html#system-description-table-header [1]
Link: https://uefi.org/specs/ACPI/6.5_A/05_ACPI_Software_Programming_Model.html#root-system-description-pointer-rsdp-structure [2]
Link: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstringop-overread [3]
Link: https://github.com/acpica/acpica/commit/8b83a8d8
Signed-off-by: Ahmed Salem <x0rw3ll@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/2248233.Mh6RI2rZIc@rjwysocki.net
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Now I understand the issue! Let me analyze the problem: **Analysis:**
**YES** - This commit should be backported to stable kernel trees. ##
Detailed Analysis: ### The Problem: The commit fixes a **buffer overread
vulnerability** in the `ACPI_VALIDATE_RSDP_SIG` macro. The issue occurs
when: 1. `ap_is_valid_header()` accepts a `struct acpi_table_header
*table` parameter 2. `struct acpi_table_header` has a `signature` field
that is only **4 bytes** (`char signature[ACPI_NAMESEG_SIZE]` where
`ACPI_NAMESEG_SIZE = 4`) 3. The original `ACPI_VALIDATE_RSDP_SIG(a)`
macro calls `strncmp(a, ACPI_SIG_RSDP, 8)` - comparing **8 bytes** 4.
When `table->signature` (4 bytes) is passed to this macro, `strncmp`
reads **beyond the bounds** of the signature field, causing a buffer
overread ### The Fix: The new macro implementation: ```c #define
ACPI_VALIDATE_RSDP_SIG(a) (!strncmp (ACPI_CAST_PTR (char, (a)),
ACPI_SIG_RSDP, (sizeof(a) < 8) ? ACPI_NAMESEG_SIZE : 8)) ``` This
intelligently chooses the comparison length: - If `sizeof(a) < 8`, it
uses `ACPI_NAMESEG_SIZE` (4 bytes) - Otherwise, it uses the full 8 bytes
for legitimate RSDP signatures ### Why This Should Be Backported: 1.
**Security Issue**: This is a buffer overread that could potentially
lead to information disclosure or memory corruption 2. **Minimal Risk**:
The change is a small, surgical fix to a macro with clear logic 3.
**Wide Impact**: The macro is used in multiple places including: -
Kernel ACPI subsystem (`drivers/acpi/acpica/tbprint.c`, `tbxfroot.c`) -
Boot code (`arch/x86/boot/compressed/acpi.c`) - ACPI tools (userspace
tools) 4. **Compiler Warnings**: This likely fixes `-Wstringop-overread`
compiler warnings, improving code quality 5. **No Functional Change**:
The fix maintains the same intended behavior while preventing the
overread 6. **Follows Stable Rules**: This is exactly the type of
important bugfix that stable trees are meant to include ### Similar
Commit Precedent: Similar commit #3 (Status: YES) shows that ACPI
compilation warning fixes have been backported before, and this is a
more serious issue (actual buffer overread vs. just truncation
warnings). The fix addresses a real memory safety issue in a fundamental
ACPI macro used throughout the kernel, making it an excellent candidate
for stable backporting.
include/acpi/actypes.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 7334037624c5c..a2bf54fb946a0 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -524,7 +524,7 @@ typedef u64 acpi_integer;
/* Support for the special RSDP signature (8 characters) */
-#define ACPI_VALIDATE_RSDP_SIG(a) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_SIG_RSDP, 8))
+#define ACPI_VALIDATE_RSDP_SIG(a) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_SIG_RSDP, (sizeof(a) < 8) ? ACPI_NAMESEG_SIZE : 8))
#define ACPI_MAKE_RSDP_SIG(dest) (memcpy (ACPI_CAST_PTR (char, (dest)), ACPI_SIG_RSDP, 8))
/* Support for OEMx signature (x can be any character) */
--
2.39.5
next prev parent reply other threads:[~2025-06-01 23:45 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-01 23:43 [PATCH AUTOSEL 5.10 01/34] drm/amdgpu/gfx6: fix CSIB handling Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 02/34] sunrpc: update nextcheck time when adding new cache entries Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 03/34] drm/bridge: analogix_dp: Add irq flag IRQF_NO_AUTOEN instead of calling disable_irq() Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 04/34] exfat: fix double free in delayed_free Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 05/34] arm64/cpuinfo: only show one cpu's info in c_show() Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 06/34] drm/msm/hdmi: add runtime PM calls to DDC transfer function Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 07/34] media: uapi: v4l: Fix V4L2_TYPE_IS_OUTPUT condition Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 08/34] drm/amd/display: Add NULL pointer checks in dm_force_atomic_commit() Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 09/34] drm/msm/a6xx: Increase HFI response timeout Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 10/34] drm/amdgpu/gfx10: fix CSIB handling Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 11/34] media: uapi: v4l: Change V4L2_TYPE_IS_CAPTURE condition Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 12/34] drm/amdgpu/gfx7: fix CSIB handling Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 13/34] ext4: ext4: unify EXT4_EX_NOCACHE|NOFAIL flags in ext4_ext_remove_space() Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 14/34] jfs: fix array-index-out-of-bounds read in add_missing_indices Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 15/34] media: rkvdec: h264: Use bytesperline and buffer height as virstride Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 16/34] media: rkvdec: Initialize the m2m context before the controls Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 17/34] sunrpc: fix race in cache cleanup causing stale nextcheck time Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 18/34] ext4: prevent stale extent cache entries caused by concurrent get es_cache Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 19/34] drm/amdgpu/gfx8: fix CSIB handling Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 20/34] drm/amdgpu/gfx9: " Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 21/34] jfs: Fix null-ptr-deref in jfs_ioc_trim Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 22/34] drm/msm/dpu: don't select single flush for active CTL blocks Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 23/34] drm/amdkfd: Set SDMA_RLCx_IB_CNTL/SWITCH_INSIDE_IB Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 24/34] media: tc358743: ignore video while HPD is low Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 25/34] media: platform: exynos4-is: Add hardware sync wait to fimc_is_hw_change_mode() Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 26/34] nios2: force update_mmu_cache on spurious tlb-permission--related pagefaults Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 27/34] PM: runtime: fix denying of auto suspend in pm_suspend_timer_fn() Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 28/34] thermal/drivers/qcom/tsens: Update conditions to strictly evaluate for IP v2+ Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 29/34] clocksource: Fix the CPUs' choice in the watchdog per CPU verification Sasha Levin
2025-06-01 23:43 ` Sasha Levin [this message]
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 31/34] ACPICA: utilities: Fix overflow check in vsnprintf() Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 32/34] cpufreq: Force sync policy boost with global boost on sysfs update Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 33/34] power: supply: bq27xxx: Retrieve again when busy Sasha Levin
2025-06-01 23:43 ` [PATCH AUTOSEL 5.10 34/34] ASoC: tas2770: Power cycle amp on ISENSE/VSENSE change Sasha Levin
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=20250601234359.3518595-30-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=acpica-devel@lists.linux.dev \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=robert.moore@intel.com \
--cc=stable@vger.kernel.org \
--cc=x0rw3ll@gmail.com \
/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
all inboxes | Powered by JetHome®