# CVE-2025-38503: btrfs: fix assertion when building free space 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, NVD) `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.27% (percentile 11, 2026-11-26)
- **CWE:** CWE-617
- **Published:** 2025-08-16T10:54:41.004Z
- **Modified:** 2026-06-17T09:17:00.123Z

## Who should check

- Anyone running Linux \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< 7c77df23324f60bcff0ea44392e2c82e9486640c; \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< f4428b2d4c68732653e93f748f538bdee639ff80; \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< 0bcc14f36c7ad37121cf5c0ae18cdde5bfad9c4e; \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< 6bbe6530b1db7b4365ce9e86144c18c5d73b2c5b; \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< 1961d20f6fa8903266ed9bd77c691924c22c8f02; dc74beca1672adf3874e6cb6c26917139e2faf01; \>= 6.0.19, \< 6.1
- Anyone running Linux 6.1

## Description

In the Linux kernel, the following vulnerability has been resolved:

btrfs: fix assertion when building free space tree

When building the free space tree with the block group tree feature
enabled, we can hit an assertion failure like this:

  BTRFS info (device loop0 state M): rebuilding free space tree
  assertion failed: ret == 0, in fs/btrfs/free-space-tree.c:1102
  ------------\[ cut here \]------------
  kernel BUG at fs/btrfs/free-space-tree.c:1102!
  Internal error: Oops - BUG: 00000000f2000800 \[\#1\]  SMP
  Modules linked in:
  CPU: 1 UID: 0 PID: 6592 Comm: syz-executor322 Not tainted 6.15.0-rc7-syzkaller-gd7fa1af5b33e \#0 PREEMPT
  Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
  pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
  pc : populate\_free\_space\_tree+0x514/0x518 fs/btrfs/free-space-tree.c:1102
  lr : populate\_free\_space\_tree+0x514/0x518 fs/btrfs/free-space-tree.c:1102
  sp : ffff8000a4ce7600
  x29: ffff8000a4ce76e0 x28: ffff0000c9bc6000 x27: ffff0000ddfff3d8
  x26: ffff0000ddfff378 x25: dfff800000000000 x24: 0000000000000001
  x23: ffff8000a4ce7660 x22: ffff70001499cecc x21: ffff0000e1d8c160
  x20: ffff0000e1cb7800 x19: ffff0000e1d8c0b0 x18: 00000000ffffffff
  x17: ffff800092f39000 x16: ffff80008ad27e48 x15: ffff700011e740c0
  x14: 1ffff00011e740c0 x13: 0000000000000004 x12: ffffffffffffffff
  x11: ffff700011e740c0 x10: 0000000000ff0100 x9 : 94ef24f55d2dbc00
  x8 : 94ef24f55d2dbc00 x7 : 0000000000000001 x6 : 0000000000000001
  x5 : ffff8000a4ce6f98 x4 : ffff80008f415ba0 x3 : ffff800080548ef0
  x2 : 0000000000000000 x1 : 0000000100000000 x0 : 000000000000003e
  Call trace:
   populate\_free\_space\_tree+0x514/0x518 fs/btrfs/free-space-tree.c:1102 (P)
   btrfs\_rebuild\_free\_space\_tree+0x14c/0x54c fs/btrfs/free-space-tree.c:1337
   btrfs\_start\_pre\_rw\_mount+0xa78/0xe10 fs/btrfs/disk-io.c:3074
   btrfs\_remount\_rw fs/btrfs/super.c:1319 \[inline\]
   btrfs\_reconfigure+0x828/0x2418 fs/btrfs/super.c:1543
   reconfigure\_super+0x1d4/0x6f0 fs/super.c:1083
   do\_remount fs/namespace.c:3365 \[inline\]
   path\_mount+0xb34/0xde0 fs/namespace.c:4200
   do\_mount fs/namespace.c:4221 \[inline\]
   \_\_do\_sys\_mount fs/namespace.c:4432 \[inline\]
   \_\_se\_sys\_mount fs/namespace.c:4409 \[inline\]
   \_\_arm64\_sys\_mount+0x3e8/0x468 fs/namespace.c:4409
   \_\_invoke\_syscall arch/arm64/kernel/syscall.c:35 \[inline\]
   invoke\_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:49
   el0\_svc\_common+0x130/0x23c arch/arm64/kernel/syscall.c:132
   do\_el0\_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151
   el0\_svc+0x58/0x17c arch/arm64/kernel/entry-common.c:767
   el0t\_64\_sync\_handler+0x78/0x108 arch/arm64/kernel/entry-common.c:786
   el0t\_64\_sync+0x198/0x19c arch/arm64/kernel/entry.S:600
  Code: f0047182 91178042 528089c3 9771d47b (d4210000)
  ---\[ end trace 0000000000000000 \]---

This happens because we are processing an empty block group, which has
no extents allocated from it, there are no items for this block group,
including the block group item since block group items are stored in a
dedicated tree when using the block group tree feature. It also means
this is the block group with the highest start offset, so there are no
higher keys in the extent root, hence btrfs\_search\_slot\_for\_read()
returns 1 (no higher key found).

Fix this by asserting 'ret' is 0 only if the block group tree feature
is not enabled, in which case we should find a block group item for
the block group since it's stored in the extent root and block group
item keys are greater than extent item keys (the value for
BTRFS\_BLOCK\_GROUP\_ITEM\_KEY is 192 and for BTRFS\_EXTENT\_ITEM\_KEY and
BTRFS\_METADATA\_ITEM\_KEY the values are 168 and 169 respectively).
In case 'ret' is 1, we just need to add a record to the free space
tree which spans the whole block group, and we can achieve this by
making 'ret == 0' as the while loop's condition.

## Affected and fixed versions

- Linux: \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< 7c77df23324f60bcff0ea44392e2c82e9486640c; \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< f4428b2d4c68732653e93f748f538bdee639ff80; \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< 0bcc14f36c7ad37121cf5c0ae18cdde5bfad9c4e; \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< 6bbe6530b1db7b4365ce9e86144c18c5d73b2c5b; \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< 1961d20f6fa8903266ed9bd77c691924c22c8f02; dc74beca1672adf3874e6cb6c26917139e2faf01; \>= 6.0.19, \< 6.1 (cvelist)
- Linux: 6.1 (cvelist)

## Mitigation

- Upgrade Linux to 6.1 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-38503. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2025-38503.md
Affected: Linux >= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, < 7c77df23324f60bcff0ea44392e2c82e9486640c; >= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, < f4428b2d4c68732653e93f748f538bdee639ff80; >= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, < 0bcc14f36c7ad37121cf5c0ae18cdde5bfad9c4e; >= 1c56ab991903dce60e905a0…
Fixed in: Linux 7c77df23324f60bcff0ea44392e2c82e9486640c, Linux 0bcc14f36c7ad37121cf5c0ae18cdde5bfad9c4e, Linux 6bbe6530b1db7b4365ce9e86144c18c5d73b2c5b, Linux 1961d20f6fa8903266ed9bd77c691924c22c8f02, Linux 6.1

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-38503 being exploited?

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

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

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

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

Linux \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< 7c77df23324f60bcff0ea44392e2c82e9486640c; \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< f4428b2d4c68732653e93f748f538bdee639ff80; \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< 0bcc14f36c7ad37121cf5c0ae18cdde5bfad9c4e; \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< 6bbe6530b1db7b4365ce9e86144c18c5d73b2c5b; \>= 1c56ab991903dce60e905a08f431c0e6f79b9b9e, \< 1961d20f6fa8903266ed9bd77c691924c22c8f02; dc74beca1672adf3874e6cb6c26917139e2faf01; \>= 6.0.19, \< 6.1; Linux 6.1.

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

Yes. Fixed in Linux 7c77df23324f60bcff0ea44392e2c82e9486640c, Linux 0bcc14f36c7ad37121cf5c0ae18cdde5bfad9c4e, Linux 6bbe6530b1db7b4365ce9e86144c18c5d73b2c5b, Linux 1961d20f6fa8903266ed9bd77c691924c22c8f02, Linux 6.1. Upgrade Linux to 6.1 or later.

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

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/7c77df23324f60bcff0ea44392e2c82e9486640c>
- patch: <https://git.kernel.org/stable/c/f4428b2d4c68732653e93f748f538bdee639ff80>
- patch: <https://git.kernel.org/stable/c/0bcc14f36c7ad37121cf5c0ae18cdde5bfad9c4e>
- patch: <https://git.kernel.org/stable/c/6bbe6530b1db7b4365ce9e86144c18c5d73b2c5b>
- patch: <https://git.kernel.org/stable/c/1961d20f6fa8903266ed9bd77c691924c22c8f02>
- other: <https://lists.debian.org/debian-lts-announce/2025/10/msg00008.html>

## 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-38503>

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