# CVE-2025-21658: btrfs: avoid NULL pointer dereference if no valid extent tree

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.29% (percentile 15, 2026-11-26)
- **CWE:** CWE-476
- **Published:** 2025-01-21T12:18:14.578Z
- **Modified:** 2026-10-30T13:17:51.060Z

## Who should check

- Anyone running Linux \>= 42437a6386ffeaaf200731e73d723ea491f3fe7d, \< 1fb37b7840fdcbf69d062a79d14afbf566b11873; \>= 42437a6386ffeaaf200731e73d723ea491f3fe7d, \< 24b85a8b0310e0144da9ab30be42e87e6476638a; \>= 42437a6386ffeaaf200731e73d723ea491f3fe7d, \< aee5f69f3e6cd82bfefaca1b70b40b6cd8f3f784; \>= 42437a6386ffeaaf200731e73d723ea491f3fe7d, \< 6aecd91a5c5b68939cf4169e32bc49f3cd2dd329
- Anyone running Linux 5.11

## Description

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.

## Affected and fixed versions

- Linux: \>= 42437a6386ffeaaf200731e73d723ea491f3fe7d, \< 1fb37b7840fdcbf69d062a79d14afbf566b11873; \>= 42437a6386ffeaaf200731e73d723ea491f3fe7d, \< 24b85a8b0310e0144da9ab30be42e87e6476638a; \>= 42437a6386ffeaaf200731e73d723ea491f3fe7d, \< aee5f69f3e6cd82bfefaca1b70b40b6cd8f3f784; \>= 42437a6386ffeaaf200731e73d723ea491f3fe7d, \< 6aecd91a5c5b68939cf4169e32bc49f3cd2dd329 (cvelist)
- Linux: 5.11 (cvelist)

## Mitigation

- Upgrade Linux to 6aecd91a5c5b68939cf4169e32bc49f3cd2dd329 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2025-21658. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2025-21658.md
Affected: Linux >= 42437a6386ffeaaf200731e73d723ea491f3fe7d, < 1fb37b7840fdcbf69d062a79d14afbf566b11873; >= 42437a6386ffeaaf200731e73d723ea491f3fe7d, < 24b85a8b0310e0144da9ab30be42e87e6476638a; >= 42437a6386ffeaaf200731e73d723ea491f3fe7d, < aee5f69f3e6cd82bfefaca1b70b40b6cd8f3f784; >= 42437a6386ffeaaf200731e…
Fixed in: Linux 1fb37b7840fdcbf69d062a79d14afbf566b11873, Linux 24b85a8b0310e0144da9ab30be42e87e6476638a, Linux 6aecd91a5c5b68939cf4169e32bc49f3cd2dd329

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2025-21658 being exploited?

There is no confirmed exploitation: CVE-2025-21658 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.29% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2025-21658?

Medium: CVSS 5.5 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2025-21658?

Linux \>= 42437a6386ffeaaf200731e73d723ea491f3fe7d, \< 1fb37b7840fdcbf69d062a79d14afbf566b11873; \>= 42437a6386ffeaaf200731e73d723ea491f3fe7d, \< 24b85a8b0310e0144da9ab30be42e87e6476638a; \>= 42437a6386ffeaaf200731e73d723ea491f3fe7d, \< aee5f69f3e6cd82bfefaca1b70b40b6cd8f3f784; \>= 42437a6386ffeaaf200731e73d723ea491f3fe7d, \< 6aecd91a5c5b68939cf4169e32bc49f3cd2dd329; Linux 5.11.

### Is there a fix for CVE-2025-21658?

Yes. Fixed in Linux 1fb37b7840fdcbf69d062a79d14afbf566b11873, Linux 24b85a8b0310e0144da9ab30be42e87e6476638a, Linux 6aecd91a5c5b68939cf4169e32bc49f3cd2dd329. Upgrade Linux to 6aecd91a5c5b68939cf4169e32bc49f3cd2dd329 or later.

### How do I check if I'm affected by CVE-2025-21658?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/24b85a8b0310e0144da9ab30be42e87e6476638a>
- patch: <https://git.kernel.org/stable/c/aee5f69f3e6cd82bfefaca1b70b40b6cd8f3f784>
- patch: <https://git.kernel.org/stable/c/6aecd91a5c5b68939cf4169e32bc49f3cd2dd329>
- other: <https://git.kernel.org/stable/c/1fb37b7840fdcbf69d062a79d14afbf566b11873>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2025-21658>

HTML: <https://flawdb.com/CVE-2025-21658> · JSON: <https://flawdb.com/api/v1/entries/CVE-2025-21658>
