# CVE-2025-38358: btrfs: fix race between async reclaim worker and close\_ctree()

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

- **Severity:** MEDIUM 4.7
- **CVSS:** 4.7 (v3.1, NVD) `CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: High; 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.15% (percentile 2, 2026-11-26)
- **CWE:** CWE-362
- **Published:** 2025-07-25T12:47:29.515Z
- **Modified:** 2026-06-17T09:16:42.003Z

## Who should check

- Anyone running Linux \>= 19e60b2a95f5d6b77d972c7bec35a11e70fd118c, \< 4693cda2c06039c875f2eef0123b22340c34bfa0; \>= 19e60b2a95f5d6b77d972c7bec35a11e70fd118c, \< a26bf338cdad3643a6e7c3d78a172baadba15c1a
- Anyone running Linux 6.15

## Description

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

btrfs: fix race between async reclaim worker and close\_ctree()

Syzbot reported an assertion failure due to an attempt to add a delayed
iput after we have set BTRFS\_FS\_STATE\_NO\_DELAYED\_IPUT in the fs\_info
state:

  WARNING: CPU: 0 PID: 65 at fs/btrfs/inode.c:3420 btrfs\_add\_delayed\_iput+0x2f8/0x370 fs/btrfs/inode.c:3420
  Modules linked in:
  CPU: 0 UID: 0 PID: 65 Comm: kworker/u8:4 Not tainted 6.15.0-next-20250530-syzkaller \#0 PREEMPT(full)
  Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
  Workqueue: btrfs-endio-write btrfs\_work\_helper
  RIP: 0010:btrfs\_add\_delayed\_iput+0x2f8/0x370 fs/btrfs/inode.c:3420
  Code: 4e ad 5d (...)
  RSP: 0018:ffffc9000213f780 EFLAGS: 00010293
  RAX: ffffffff83c635b7 RBX: ffff888058920000 RCX: ffff88801c769e00
  RDX: 0000000000000000 RSI: 0000000000000100 RDI: 0000000000000000
  RBP: 0000000000000001 R08: ffff888058921b67 R09: 1ffff1100b12436c
  R10: dffffc0000000000 R11: ffffed100b12436d R12: 0000000000000001
  R13: dffffc0000000000 R14: ffff88807d748000 R15: 0000000000000100
  FS:  0000000000000000(0000) GS:ffff888125c53000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 00002000000bd038 CR3: 000000006a142000 CR4: 00000000003526f0
  DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
  DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
  Call Trace:
   \<TASK\>
   btrfs\_put\_ordered\_extent+0x19f/0x470 fs/btrfs/ordered-data.c:635
   btrfs\_finish\_one\_ordered+0x11d8/0x1b10 fs/btrfs/inode.c:3312
   btrfs\_work\_helper+0x399/0xc20 fs/btrfs/async-thread.c:312
   process\_one\_work kernel/workqueue.c:3238 \[inline\]
   process\_scheduled\_works+0xae1/0x17b0 kernel/workqueue.c:3321
   worker\_thread+0x8a0/0xda0 kernel/workqueue.c:3402
   kthread+0x70e/0x8a0 kernel/kthread.c:464
   ret\_from\_fork+0x3fc/0x770 arch/x86/kernel/process.c:148
   ret\_from\_fork\_asm+0x1a/0x30 arch/x86/entry/entry\_64.S:245
   \</TASK\>

This can happen due to a race with the async reclaim worker like this:

1) The async metadata reclaim worker enters shrink\_delalloc(), which calls
   btrfs\_start\_delalloc\_roots() with an nr\_pages argument that has a value
   less than LONG\_MAX, and that in turn enters start\_delalloc\_inodes(),
   which sets the local variable 'full\_flush' to false because
   wbc-\>nr\_to\_write is less than LONG\_MAX;

2) There it finds inode X in a root's delalloc list, grabs a reference for
   inode X (with igrab()), and triggers writeback for it with
   filemap\_fdatawrite\_wbc(), which creates an ordered extent for inode X;

3) The unmount sequence starts from another task, we enter close\_ctree()
   and we flush the workqueue fs\_info-\>endio\_write\_workers, which waits
   for the ordered extent for inode X to complete and when dropping the
   last reference of the ordered extent, with btrfs\_put\_ordered\_extent(),
   when we call btrfs\_add\_delayed\_iput() we don't add the inode to the
   list of delayed iputs because it has a refcount of 2, so we decrement
   it to 1 and return;

4) Shortly after at close\_ctree() we call btrfs\_run\_delayed\_iputs() which
   runs all delayed iputs, and then we set BTRFS\_FS\_STATE\_NO\_DELAYED\_IPUT
   in the fs\_info state;

5) The async reclaim worker, after calling filemap\_fdatawrite\_wbc(), now
   calls btrfs\_add\_delayed\_iput() for inode X and there we trigger an
   assertion failure since the fs\_info state has the flag
   BTRFS\_FS\_STATE\_NO\_DELAYED\_IPUT set.

Fix this by setting BTRFS\_FS\_STATE\_NO\_DELAYED\_IPUT only after we wait for
the async reclaim workers to finish, after we call cancel\_work\_sync() for
them at close\_ctree(), and by running delayed iputs after wait for the
reclaim workers to finish and before setting the bit.

This race was recently introduced by commit 19e60b2a95f5 ("btrfs: add
extra warning if delayed iput is added when it's not allowed"). Without
the new validation at btrfs\_add\_delayed\_iput(), 
---truncated---

## Affected and fixed versions

- Linux: \>= 19e60b2a95f5d6b77d972c7bec35a11e70fd118c, \< 4693cda2c06039c875f2eef0123b22340c34bfa0; \>= 19e60b2a95f5d6b77d972c7bec35a11e70fd118c, \< a26bf338cdad3643a6e7c3d78a172baadba15c1a (cvelist)
- Linux: 6.15 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2025-38358.md
Affected: Linux >= 19e60b2a95f5d6b77d972c7bec35a11e70fd118c, < 4693cda2c06039c875f2eef0123b22340c34bfa0; >= 19e60b2a95f5d6b77d972c7bec35a11e70fd118c, < a26bf338cdad3643a6e7c3d78a172baadba15c1a; Linux 6.15
Fixed in: Linux 4693cda2c06039c875f2eef0123b22340c34bfa0

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

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

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

Medium: CVSS 4.7 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed). The attack needs conditions outside the attacker's control, which makes it harder.

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

Linux \>= 19e60b2a95f5d6b77d972c7bec35a11e70fd118c, \< 4693cda2c06039c875f2eef0123b22340c34bfa0; \>= 19e60b2a95f5d6b77d972c7bec35a11e70fd118c, \< a26bf338cdad3643a6e7c3d78a172baadba15c1a; Linux 6.15.

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

Yes. Fixed in Linux 4693cda2c06039c875f2eef0123b22340c34bfa0. No fix listed yet: follow the vendor advisory.

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

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/4693cda2c06039c875f2eef0123b22340c34bfa0>
- patch: <https://git.kernel.org/stable/c/a26bf338cdad3643a6e7c3d78a172baadba15c1a>

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

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