# CVE-2025-21942: btrfs: zoned: fix extent range end unlock in cow\_file\_range()

> 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.28% (percentile 13, 2026-11-28)
- **CWE:** CWE-835
- **Published:** 2025-04-01T15:41:06.977Z
- **Modified:** 2026-10-30T13:17:54.407Z

## Who should check

- Anyone running Linux \>= 10b3772292bf1be45604ba83fd9650eb94382e78, \< 5f4863cfb29a7b4fe7625ce148d0b9000b75b802; \>= 692cf71173bb41395c855acbbbe197d3aedfa5d4, \< 3fcff2f55389306482ab049b4321bda49495e546; \>= 06f364284794f149d2abc167c11d556cf20c954b, \< 5a4041f2c47247575a6c2e53ce14f7b0ac946c33; 29418ebb8b4d4d090e403d395a6db7e8455331f7; 4ace6fb49c8be23b005828763d8b0d0bb0f3b0c5; \>= 6.1.191, \< 6.2; \>= 6.6.160, \< 6.7
- Anyone running Linux \>= 6.13.2, \< 6.13.7

## Description

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

btrfs: zoned: fix extent range end unlock in cow\_file\_range()

Running generic/751 on the for-next branch often results in a hang like
below. They are both stack by locking an extent. This suggests someone
forget to unlock an extent.

  INFO: task kworker/u128:1:12 blocked for more than 323 seconds.
        Not tainted 6.13.0-BTRFS-ZNS+ \#503
  "echo 0 \> /proc/sys/kernel/hung\_task\_timeout\_secs" disables this message.
  task:kworker/u128:1  state:D stack:0     pid:12    tgid:12    ppid:2      flags:0x00004000
  Workqueue: btrfs-fixup btrfs\_work\_helper \[btrfs\]
  Call Trace:
   \<TASK\>
   \_\_schedule+0x534/0xdd0
   schedule+0x39/0x140
   \_\_lock\_extent+0x31b/0x380 \[btrfs\]
   ? \_\_pfx\_autoremove\_wake\_function+0x10/0x10
   btrfs\_writepage\_fixup\_worker+0xf1/0x3a0 \[btrfs\]
   btrfs\_work\_helper+0xff/0x480 \[btrfs\]
   ? lock\_release+0x178/0x2c0
   process\_one\_work+0x1ee/0x570
   ? srso\_return\_thunk+0x5/0x5f
   worker\_thread+0x1d1/0x3b0
   ? \_\_pfx\_worker\_thread+0x10/0x10
   kthread+0x10b/0x230
   ? \_\_pfx\_kthread+0x10/0x10
   ret\_from\_fork+0x30/0x50
   ? \_\_pfx\_kthread+0x10/0x10
   ret\_from\_fork\_asm+0x1a/0x30
   \</TASK\>
  INFO: task kworker/u134:0:184 blocked for more than 323 seconds.
        Not tainted 6.13.0-BTRFS-ZNS+ \#503
  "echo 0 \> /proc/sys/kernel/hung\_task\_timeout\_secs" disables this message.
  task:kworker/u134:0  state:D stack:0     pid:184   tgid:184   ppid:2      flags:0x00004000
  Workqueue: writeback wb\_workfn (flush-btrfs-4)
  Call Trace:
   \<TASK\>
   \_\_schedule+0x534/0xdd0
   schedule+0x39/0x140
   \_\_lock\_extent+0x31b/0x380 \[btrfs\]
   ? \_\_pfx\_autoremove\_wake\_function+0x10/0x10
   find\_lock\_delalloc\_range+0xdb/0x260 \[btrfs\]
   writepage\_delalloc+0x12f/0x500 \[btrfs\]
   ? srso\_return\_thunk+0x5/0x5f
   extent\_write\_cache\_pages+0x232/0x840 \[btrfs\]
   btrfs\_writepages+0x72/0x130 \[btrfs\]
   do\_writepages+0xe7/0x260
   ? srso\_return\_thunk+0x5/0x5f
   ? lock\_acquire+0xd2/0x300
   ? srso\_return\_thunk+0x5/0x5f
   ? find\_held\_lock+0x2b/0x80
   ? wbc\_attach\_and\_unlock\_inode.part.0+0x102/0x250
   ? wbc\_attach\_and\_unlock\_inode.part.0+0x102/0x250
   \_\_writeback\_single\_inode+0x5c/0x4b0
   writeback\_sb\_inodes+0x22d/0x550
   \_\_writeback\_inodes\_wb+0x4c/0xe0
   wb\_writeback+0x2f6/0x3f0
   wb\_workfn+0x32a/0x510
   process\_one\_work+0x1ee/0x570
   ? srso\_return\_thunk+0x5/0x5f
   worker\_thread+0x1d1/0x3b0
   ? \_\_pfx\_worker\_thread+0x10/0x10
   kthread+0x10b/0x230
   ? \_\_pfx\_kthread+0x10/0x10
   ret\_from\_fork+0x30/0x50
   ? \_\_pfx\_kthread+0x10/0x10
   ret\_from\_fork\_asm+0x1a/0x30
   \</TASK\>

This happens because we have another success path for the zoned mode. When
there is no active zone available, btrfs\_reserve\_extent() returns
-EAGAIN. In this case, we have two reactions.

(1) If the given range is never allocated, we can only wait for someone
    to finish a zone, so wait on BTRFS\_FS\_NEED\_ZONE\_FINISH bit and retry
    afterward.

(2) Or, if some allocations are already done, we must bail out and let
    the caller to send IOs for the allocation. This is because these IOs
    may be necessary to finish a zone.

The commit 06f364284794 ("btrfs: do proper folio cleanup when
cow\_file\_range() failed") moved the unlock code from the inside of the
loop to the outside. So, previously, the allocated extents are unlocked
just after the allocation and so before returning from the function.
However, they are no longer unlocked on the case (2) above. That caused
the hang issue.

Fix the issue by modifying the 'end' to the end of the allocated
range. Then, we can exit the loop and the same unlock code can properly
handle the case.

## Affected and fixed versions

- Linux: \>= 10b3772292bf1be45604ba83fd9650eb94382e78, \< 5f4863cfb29a7b4fe7625ce148d0b9000b75b802; \>= 692cf71173bb41395c855acbbbe197d3aedfa5d4, \< 3fcff2f55389306482ab049b4321bda49495e546; \>= 06f364284794f149d2abc167c11d556cf20c954b, \< 5a4041f2c47247575a6c2e53ce14f7b0ac946c33; 29418ebb8b4d4d090e403d395a6db7e8455331f7; 4ace6fb49c8be23b005828763d8b0d0bb0f3b0c5; \>= 6.1.191, \< 6.2; \>= 6.6.160, \< 6.7 (cvelist)
- Linux: \>= 6.13.2, \< 6.13.7 (cvelist)

## Mitigation

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

Details: https://flawdb.com/CVE-2025-21942.md
Affected: Linux >= 10b3772292bf1be45604ba83fd9650eb94382e78, < 5f4863cfb29a7b4fe7625ce148d0b9000b75b802; >= 692cf71173bb41395c855acbbbe197d3aedfa5d4, < 3fcff2f55389306482ab049b4321bda49495e546; >= 06f364284794f149d2abc167c11d556cf20c954b, < 5a4041f2c47247575a6c2e53ce14f7b0ac946c33; 29418ebb8b4d4d090e403d395a…
Fixed in: Linux 5f4863cfb29a7b4fe7625ce148d0b9000b75b802, Linux 3fcff2f55389306482ab049b4321bda49495e546, Linux 5a4041f2c47247575a6c2e53ce14f7b0ac946c33, Linux 6.2, Linux 6.7, Linux 6.13.7

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

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

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

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

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

Linux \>= 10b3772292bf1be45604ba83fd9650eb94382e78, \< 5f4863cfb29a7b4fe7625ce148d0b9000b75b802; \>= 692cf71173bb41395c855acbbbe197d3aedfa5d4, \< 3fcff2f55389306482ab049b4321bda49495e546; \>= 06f364284794f149d2abc167c11d556cf20c954b, \< 5a4041f2c47247575a6c2e53ce14f7b0ac946c33; 29418ebb8b4d4d090e403d395a6db7e8455331f7; 4ace6fb49c8be23b005828763d8b0d0bb0f3b0c5; \>= 6.1.191, \< 6.2; \>= 6.6.160, \< 6.7; Linux \>= 6.13.2, \< 6.13.7.

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

Yes. Fixed in Linux 5f4863cfb29a7b4fe7625ce148d0b9000b75b802, Linux 3fcff2f55389306482ab049b4321bda49495e546, Linux 5a4041f2c47247575a6c2e53ce14f7b0ac946c33, Linux 6.2, Linux 6.7, Linux 6.13.7. Upgrade Linux to 6.7 or later. Upgrade Linux to 6.13.7 or later.

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

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/5f4863cfb29a7b4fe7625ce148d0b9000b75b802>
- patch: <https://git.kernel.org/stable/c/3fcff2f55389306482ab049b4321bda49495e546>
- patch: <https://git.kernel.org/stable/c/5a4041f2c47247575a6c2e53ce14f7b0ac946c33>

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

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