CVE-2025-21658: btrfs: avoid NULL pointer dereference if no valid extent tree
In the Linux kernel, the following vulnerability has been resolved:
btrfs: avoid NULL pointer dereference if no valid extent tree
[BUG]
Syzbot reported a crash with the following call trace:
BTRFS info (device loop0): scrub: started on devid 1
BUG: kernel NULL pointer dereference, address: 0000000000000208
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 106e70067 P4D 106e70067 PUD 107143067 PMD 0
Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI
CPU: 1 UID: 0 PID: 689 Comm: repro Kdump: loaded Tainted: G O 6.13.0-rc4-custom+ #206
Tainted: [O]=OOT_MODULE
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 02/02/2022
RIP: 0010:find_first_extent_item+0x26/0x1f0 [btrfs]
Call Trace:
<TASK>
scrub_find_fill_first_stripe+0x13d/0x3b0 [btrfs]
scrub_simple_mirror+0x175/0x260 [btrfs]
scrub_stripe+0x5d4/0x6c0 [btrfs]
scrub_chunk+0xbb/0x170 [btrfs]
scrub_enumerate_chunks+0x2f4/0x5f0 [btrfs]
btrfs_scrub_dev+0x240/0x600 [btrfs]
btrfs_ioctl+0x1dc8/0x2fa0 [btrfs]
? do_sys_openat2+0xa5/0xf0
__x64_sys_ioctl+0x97/0xc0
do_syscall_64+0x4f/0x120
entry_SYSCALL_64_after_hwframe+0x76/0x7e
</TASK>
[CAUSE]
The reproducer is using a corrupted image where extent tree root is
corrupted, thus forcing to use "rescue=all,ro" mount option to mount the
image.
Then it triggered a scrub, but since scrub relies on extent tree to find
where the data/metadata extents are, scrub_find_fill_first_stripe()
relies on an non-empty extent root.
But unfortunately scrub_find_fill_first_stripe() doesn't really expect
an NULL pointer for extent root, it use extent_root to grab fs_info and
triggered a NULL pointer dereference.
[FIX]
Add an extra check for a valid extent root at the beginning of
scrub_find_fill_first_stripe().
The new error path is introduced by 42437a6386ff ("btrfs: introduce
mount option rescue=ignorebadroots"), but that's pretty old, and later
commit b979547513ff ("btrfs: scrub: introduce helper to find and fill
sector info for a scrub_stripe") changed how we do scrub.
So for kernels older than 6.6, the fix will need manual backport.
Security readout for executives and security teams
Plain-English summary
CVE-2025-21658 is a Linux kernel Btrfs crash bug. A corrupted Btrfs image mounted in rescue read-only mode can trigger a NULL pointer dereference during scrub, causing a kernel crash. The main business impact is local denial of service, not data theft or remote compromise.
Executive priority
Treat as a routine-to-priority kernel availability fix for Btrfs systems. It is not supported as remotely exploitable by the provided sources, but a crash in production can still disrupt services. Patch during the next appropriate maintenance window, faster for systems handling untrusted images.
Technical view
Btrfs scrub code can dereference a NULL extent tree root when operating on a corrupted filesystem image mounted with rescue options. The reported Syzbot trace crashes in find_first_extent_item via scrub_find_fill_first_stripe. The kernel fix adds a validity check for the extent root; older kernels may require manual backporting.
Likely exposure
Exposure is most relevant to Linux systems using Btrfs, especially environments processing untrusted or corrupted filesystem images. Practical impact requires local access and conditions allowing the filesystem image to be mounted and scrubbed. Distribution backports determine whether a specific kernel build is vulnerable.
Exploitation context
The public record describes a Syzbot reproducer and kernel crash path. It does not cite active exploitation, and the CVE is not listed as KEV in the provided bundle. The CVSS vector is local, low complexity, low privilege, and high availability impact.
Researcher notes
Root cause is CWE-476 in Btrfs scrub when extent_root is NULL after mounting a corrupted image with rescue behavior. The fix path is explicit, but exact affected distro kernels require vendor mapping. Sources mention older-than-6.6 kernels may need manual backporting.
Mitigation direction
Update to a kernel or vendor package containing the referenced Btrfs stable fixes.
Check your Linux distribution advisory for backported fixes and affected kernel builds.
Limit handling of untrusted Btrfs images on production systems until patched.
Avoid unnecessary Btrfs scrub operations on corrupted rescue-mounted images.
Validation and detection
Inventory systems using Btrfs filesystems or Btrfs image-processing workflows.
Confirm running kernel versions against vendor advisories and stable fix commits.
Review whether kernels include the extent-root validity check in Btrfs scrub code.
Prioritize hosts where local users can mount or process filesystem images.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-476: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-476 · source CWE mapping
NULL Pointer Dereference
NULL Pointer Dereference represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.