CVE-2025-21658

Source
https://nvd.nist.gov/vuln/detail/CVE-2025-21658
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2025-21658.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2025-21658
Downstream
Related
Published
2025-01-21T13:15:09Z
Modified
2025-10-01T20:18:17Z
Severity
  • 5.5 (Medium) CVSS_V3 - CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H CVSS Calculator
Summary
[none]
Details

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: errorcode(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]=OOTMODULE Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 02/02/2022 RIP: 0010:findfirstextentitem+0x26/0x1f0 [btrfs] Call Trace: <TASK> scrubfindfillfirststripe+0x13d/0x3b0 [btrfs] scrubsimplemirror+0x175/0x260 [btrfs] scrubstripe+0x5d4/0x6c0 [btrfs] scrubchunk+0xbb/0x170 [btrfs] scrubenumeratechunks+0x2f4/0x5f0 [btrfs] btrfsscrubdev+0x240/0x600 [btrfs] btrfsioctl+0x1dc8/0x2fa0 [btrfs] ? dosysopenat2+0xa5/0xf0 _x64sysioctl+0x97/0xc0 dosyscall64+0x4f/0x120 entrySYSCALL64after_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, scrubfindfillfirststripe() relies on an non-empty extent root.

But unfortunately scrubfindfillfirststripe() doesn't really expect an NULL pointer for extent root, it use extentroot to grab fsinfo and triggered a NULL pointer dereference.

[FIX] Add an extra check for a valid extent root at the beginning of scrubfindfillfirststripe().

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.

References

Affected packages