From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Ard Biesheuvel <ardb@kernel.org>,
Hanjun Guo <guohanjun@huawei.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Sasha Levin <sashal@kernel.org>,
rafael@kernel.org, bp@alien8.de, zhangdandan@uniontech.com,
linux-acpi@vger.kernel.org
Subject: [PATCH AUTOSEL 6.19-5.10] EFI/CPER: don't dump the entire memory region
Date: Wed, 11 Feb 2026 07:30:24 -0500 [thread overview]
Message-ID: <20260211123112.1330287-14-sashal@kernel.org> (raw)
In-Reply-To: <20260211123112.1330287-1-sashal@kernel.org>
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
[ Upstream commit 55cc6fe5716f678f06bcb95140882dfa684464ec ]
The current logic at cper_print_fw_err() doesn't check if the
error record length is big enough to handle offset. On a bad firmware,
if the ofset is above the actual record, length -= offset will
underflow, making it dump the entire memory.
The end result can be:
- the logic taking a lot of time dumping large regions of memory;
- data disclosure due to the memory dumps;
- an OOPS, if it tries to dump an unmapped memory region.
Fix it by checking if the section length is too small before doing
a hex dump.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
[ rjw: Subject tweaks ]
Link: https://patch.msgid.link/1752b5ba63a3e2f148ddee813b36c996cc617e86.1767871950.git.mchehab+huawei@kernel.org
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
This completes my analysis. Here is the comprehensive summary:
---
## Detailed Analysis
### 1. COMMIT MESSAGE ANALYSIS
The commit message is extremely clear about the bug and its
consequences:
- **Root cause**: `cper_print_fw_err()` does not validate that the error
record's `length` is large enough to accommodate the computed
`offset`. On buggy firmware, if offset > length, the unsigned
subtraction `length -= offset` underflows.
- **Three consequences**: (1) Massive kernel log output dumping huge
memory regions (DoS), (2) Data disclosure from kernel memory dumps,
(3) Kernel OOPS if it accesses unmapped memory.
The commit is authored by Mauro Carvalho Chehab (a prominent Linux
kernel developer), reviewed by Jonathan Cameron, acked by Ard Biesheuvel
(the EFI subsystem maintainer), and merged by Rafael J. Wysocki.
### 2. CODE CHANGE ANALYSIS
The fix is exactly **5 lines** of new code, inserted at lines 563-567 of
`cper.c`:
```563:567:drivers/firmware/efi/cper.c
if (offset > length) {
printk("%s""error section length is too small:
offset=%d, length=%d\n",
pfx, offset, length);
return;
}
```
**The bug mechanism in detail:**
The `struct cper_sec_fw_err_rec_ref` is packed:
- `record_type` (u8): offset 0
- `revision` (u8): offset 1
- `reserved[6]` (u8): offset 2
- `record_identifier` (u64): offset 8
- `record_identifier_guid` (guid_t, 16 bytes): offset 16
- Total `sizeof` = 32
The function computes an `offset` based on the `revision` field from
firmware:
- revision 0: offset = 16 (`offsetof(record_identifier_guid)`)
- revision 1: offset = 8 (`offsetof(record_identifier)`)
- revision ≥ 2: offset = 32 (`sizeof(*fw_err)`)
The caller in `cper_estatus_print_section()` (line 682) only validates
`gdata->error_data_length >= SZ_16` (16 bytes) before calling
`cper_print_fw_err()`. This means:
- **Any firmware reporting revision ≥ 2 with `error_data_length` between
16 and 31 bytes causes the underflow.** For example, with `length=16`
and `revision=2`, `offset=32`, and `length -= offset` wraps the `u32`
to **0xFFFFFFF0 (4,294,967,280 bytes = ~4 GB)**.
This massive value is then passed to `print_hex_dump()` which loops
through the buffer printing 16 bytes per line. This causes:
1. The kernel to attempt reading ~4GB of arbitrary memory past the
firmware error record
2. Massive printk output flooding the kernel log
3. A kernel OOPS/crash when accessing unmapped memory regions
### 3. CLASSIFICATION
This is unambiguously a **security and stability bug fix**:
- **Integer underflow** leading to out-of-bounds memory access
- **Information disclosure** (kernel memory contents leaked via printk)
- **Denial of service** (system hangs printing ~4GB of memory)
- **Kernel crash** (OOPS when accessing unmapped addresses)
This is triggered by bad firmware data, which is a realistic scenario -
the CPER subsystem exists specifically to parse firmware-provided error
records, and firmware is notoriously buggy.
### 4. SCOPE AND RISK ASSESSMENT
- **Lines changed**: +5 lines (one bounds check + error message +
return)
- **Files touched**: 1 file (`drivers/firmware/efi/cper.c`)
- **Complexity**: Minimal - a simple comparison before subtraction
- **Risk of regression**: Essentially zero. The fix adds a guard that
only fires when `offset > length`, which is an invalid/corrupt
condition. Normal firmware error records will have length ≥ offset, so
the new check won't affect normal operation.
- **Subsystem maturity**: The EFI/CPER subsystem is mature and stable
### 5. USER IMPACT
- **Who is affected**: All systems with EFI firmware that produce CPER
records (most modern x86 and ARM64 systems)
- **Trigger**: Buggy firmware producing a Firmware Error Record
Reference section with a small section length and revision ≥ 2
- **Severity**: HIGH - ranges from system hang to kernel crash to
information disclosure
- **Real-world likelihood**: Moderate. CPER records are generated by
firmware during hardware errors, and the commit message indicates this
was found during real firmware debugging ("On a bad firmware...")
### 6. STABILITY INDICATORS
- Reviewed-by: Jonathan Cameron (experienced kernel developer)
- Acked-by: Ard Biesheuvel (EFI subsystem maintainer)
- Merged by: Rafael J. Wysocki (ACPI/PM subsystem maintainer)
- Author: Mauro Carvalho Chehab (long-time kernel maintainer)
### 7. DEPENDENCY CHECK
- The buggy code was introduced in **v5.7** (commit `3d8c11efd528`,
"efi: cper: Add support for printing Firmware Error Record
Reference").
- The `cper_print_fw_err()` function has **never been modified** since
its introduction - the fix will apply cleanly to all stable trees from
5.10.y onward.
- The fix is completely self-contained with **zero dependencies** on
other patches.
- The surrounding context (both before and after the insertion point) is
identical to the original code from 2020.
### Summary
This is a textbook stable-tree backport candidate. It fixes a real
security/stability bug (unsigned integer underflow causing ~4GB out-of-
bounds memory access) with a tiny, obviously correct, 5-line bounds
check. The fix has been reviewed and acked by the relevant subsystem
maintainer, has zero risk of regression, no dependencies, and applies
cleanly to all stable trees where the vulnerable code exists (5.10.y
through 6.12.y and beyond). The bug has been present since v5.7 and
affects all EFI systems.
**YES**
drivers/firmware/efi/cper.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
index bd99802cb0cad..09a4f0168df80 100644
--- a/drivers/firmware/efi/cper.c
+++ b/drivers/firmware/efi/cper.c
@@ -560,6 +560,11 @@ static void cper_print_fw_err(const char *pfx,
} else {
offset = sizeof(*fw_err);
}
+ if (offset > length) {
+ printk("%s""error section length is too small: offset=%d, length=%d\n",
+ pfx, offset, length);
+ return;
+ }
buf += offset;
length -= offset;
--
2.51.0
next prev parent reply other threads:[~2026-02-11 12:31 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-11 12:30 [PATCH AUTOSEL 6.19-5.10] s390/perf: Disable register readout on sampling events Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.10] arm64: Add support for TSV110 Spectre-BHB mitigation Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.10] xenbus: Use .freeze/.thaw to handle xenbus devices Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.10] s390/purgatory: Add -Wno-default-const-init-unsafe to KBUILD_CFLAGS Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.18] s390/boot: " Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.1] perf/arm-cmn: Support CMN-600AE Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.18] ntfs: ->d_compare() must not block Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.12] ACPI: x86: s2idle: Invoke Microsoft _DSM Function 9 (Turn On Display) Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.12] block: decouple secure erase size limit from discard size limit Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.10] sparc: don't reference obsolete termio struct for TC* constants Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.10] EFI/CPER: don't go past the ARM processor CPER record buffer Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19] ACPI: scan: Use async schedule function in acpi_scan_clear_dep_fn() Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.6] cpufreq: dt-platdev: Block the driver from probing on more QC platforms Sasha Levin
2026-02-11 12:30 ` Sasha Levin [this message]
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.12] ACPI: battery: fix incorrect charging status when current is zero Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.18] rust: cpufreq: always inline functions using build_assert with arguments Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.18] blk-mq-sched: unify elevators checking for async requests Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.10] x86/xen/pvh: Enable PAE mode for 32-bit guest only when CONFIG_X86_PAE is set Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.12] APEI/GHES: ARM processor Error: don't go past allocated memory Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.18] md raid: fix hang when stopping arrays with metadata through dm-raid Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.10] tools/power cpupower: Reset errno before strtoull() Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.10] sparc: Synchronize user stack on fork and clone Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.10] blk-mq-debugfs: add missing debugfs_mutex in blk_mq_debugfs_register_hctxs() Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.10] rnbd-srv: Zero the rsp buffer before using it Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.12] alpha: fix user-space corruption during memory compaction Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.10] ACPICA: Abort AML bytecode execution when executing AML_FATAL_OP Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19] arm64: mte: Set TCMA1 whenever MTE is present in the kernel Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.18] tools/cpupower: Fix inverted APERF capability check Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.15] ACPI: processor: Fix NULL-pointer dereference in acpi_processor_errata_piix4() Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.12] ACPI: resource: Add JWIPC JVC9100 to irq1_level_low_skip_override[] Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.6] perf/cxlpmu: Replace IRQF_ONESHOT with IRQF_NO_THREAD Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.6] md-cluster: fix NULL pointer dereference in process_metadata_update Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-5.10] APEI/GHES: ensure that won't go past CPER allocated record Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.12] powercap: intel_rapl: Add PL4 support for Ice Lake Sasha Levin
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19-6.18] io_uring/timeout: annotate data race in io_flush_timeouts() 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=20260211123112.1330287-14-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=guohanjun@huawei.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-acpi@vger.kernel.org \
--cc=mchehab+huawei@kernel.org \
--cc=patches@lists.linux.dev \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=stable@vger.kernel.org \
--cc=zhangdandan@uniontech.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