CVE-2025-21658
Severity CVSS v4.0:
Pending analysis
Type:
CWE-476
NULL Pointer Dereference
Publication date:
21/01/2025
Last modified:
01/10/2025
Description
In the Linux kernel, the following vulnerability has been resolved:<br />
<br />
btrfs: avoid NULL pointer dereference if no valid extent tree<br />
<br />
[BUG]<br />
Syzbot reported a crash with the following call trace:<br />
<br />
BTRFS info (device loop0): scrub: started on devid 1<br />
BUG: kernel NULL pointer dereference, address: 0000000000000208<br />
#PF: supervisor read access in kernel mode<br />
#PF: error_code(0x0000) - not-present page<br />
PGD 106e70067 P4D 106e70067 PUD 107143067 PMD 0<br />
Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI<br />
CPU: 1 UID: 0 PID: 689 Comm: repro Kdump: loaded Tainted: G O 6.13.0-rc4-custom+ #206<br />
Tainted: [O]=OOT_MODULE<br />
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 02/02/2022<br />
RIP: 0010:find_first_extent_item+0x26/0x1f0 [btrfs]<br />
Call Trace:<br />
<br />
scrub_find_fill_first_stripe+0x13d/0x3b0 [btrfs]<br />
scrub_simple_mirror+0x175/0x260 [btrfs]<br />
scrub_stripe+0x5d4/0x6c0 [btrfs]<br />
scrub_chunk+0xbb/0x170 [btrfs]<br />
scrub_enumerate_chunks+0x2f4/0x5f0 [btrfs]<br />
btrfs_scrub_dev+0x240/0x600 [btrfs]<br />
btrfs_ioctl+0x1dc8/0x2fa0 [btrfs]<br />
? do_sys_openat2+0xa5/0xf0<br />
__x64_sys_ioctl+0x97/0xc0<br />
do_syscall_64+0x4f/0x120<br />
entry_SYSCALL_64_after_hwframe+0x76/0x7e<br />
<br />
<br />
[CAUSE]<br />
The reproducer is using a corrupted image where extent tree root is<br />
corrupted, thus forcing to use "rescue=all,ro" mount option to mount the<br />
image.<br />
<br />
Then it triggered a scrub, but since scrub relies on extent tree to find<br />
where the data/metadata extents are, scrub_find_fill_first_stripe()<br />
relies on an non-empty extent root.<br />
<br />
But unfortunately scrub_find_fill_first_stripe() doesn&#39;t really expect<br />
an NULL pointer for extent root, it use extent_root to grab fs_info and<br />
triggered a NULL pointer dereference.<br />
<br />
[FIX]<br />
Add an extra check for a valid extent root at the beginning of<br />
scrub_find_fill_first_stripe().<br />
<br />
The new error path is introduced by 42437a6386ff ("btrfs: introduce<br />
mount option rescue=ignorebadroots"), but that&#39;s pretty old, and later<br />
commit b979547513ff ("btrfs: scrub: introduce helper to find and fill<br />
sector info for a scrub_stripe") changed how we do scrub.<br />
<br />
So for kernels older than 6.6, the fix will need manual backport.
Impact
Base Score 3.x
5.50
Severity 3.x
MEDIUM
Vulnerable products and versions
| CPE | From | Up to |
|---|---|---|
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.11 (including) | 6.6.72 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.7 (including) | 6.12.10 (excluding) |
| cpe:2.3:o:linux:linux_kernel:6.13:rc1:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.13:rc2:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.13:rc3:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.13:rc4:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.13:rc5:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.13:rc6:*:*:*:*:*:* |
To consult the complete list of CPE names with products and versions, see this page



