# CVE-2022-50089: btrfs: ensure pages are unlocked on cow\_file\_range() failure

> 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-26)
- **Published:** 2025-06-18T11:02:29.451Z
- **Modified:** 2026-06-17T05:22:44.157Z

## Who should check

- Anyone running Linux \>= 42c011000963442ce533d92a492c4a057b2f5a46, \< b367f125c80fa838eae49e3b138dc67dfc9f46ef; \>= 42c011000963442ce533d92a492c4a057b2f5a46, \< 9535ec371d741fa037e37eddc0a5b25ba82d0027; \>= 42c011000963442ce533d92a492c4a057b2f5a46, \< e160aa87c87a9c4e0c8d1430235f715a3a91e2cd; \>= 42c011000963442ce533d92a492c4a057b2f5a46, \< 9ce7466f372d83054c7494f6b3e4b9abaf3f0355
- Anyone running Linux 5.12

## Description

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

btrfs: ensure pages are unlocked on cow\_file\_range() failure

There is a hung\_task report on zoned btrfs like below.

https://github.com/naota/linux/issues/59

  \[726.328648\] INFO: task rocksdb:high0:11085 blocked for more than 241 seconds.
  \[726.329839\]       Not tainted 5.16.0-rc1+ \#1
  \[726.330484\] "echo 0 \> /proc/sys/kernel/hung\_task\_timeout\_secs" disables this message.
  \[726.331603\] task:rocksdb:high0   state:D stack:    0 pid:11085 ppid: 11082 flags:0x00000000
  \[726.331608\] Call Trace:
  \[726.331611\]  \<TASK\>
  \[726.331614\]  \_\_schedule+0x2e5/0x9d0
  \[726.331622\]  schedule+0x58/0xd0
  \[726.331626\]  io\_schedule+0x3f/0x70
  \[726.331629\]  \_\_folio\_lock+0x125/0x200
  \[726.331634\]  ? find\_get\_entries+0x1bc/0x240
  \[726.331638\]  ? filemap\_invalidate\_unlock\_two+0x40/0x40
  \[726.331642\]  truncate\_inode\_pages\_range+0x5b2/0x770
  \[726.331649\]  truncate\_inode\_pages\_final+0x44/0x50
  \[726.331653\]  btrfs\_evict\_inode+0x67/0x480
  \[726.331658\]  evict+0xd0/0x180
  \[726.331661\]  iput+0x13f/0x200
  \[726.331664\]  do\_unlinkat+0x1c0/0x2b0
  \[726.331668\]  \_\_x64\_sys\_unlink+0x23/0x30
  \[726.331670\]  do\_syscall\_64+0x3b/0xc0
  \[726.331674\]  entry\_SYSCALL\_64\_after\_hwframe+0x44/0xae
  \[726.331677\] RIP: 0033:0x7fb9490a171b
  \[726.331681\] RSP: 002b:00007fb943ffac68 EFLAGS: 00000246 ORIG\_RAX: 0000000000000057
  \[726.331684\] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fb9490a171b
  \[726.331686\] RDX: 00007fb943ffb040 RSI: 000055a6bbe6ec20 RDI: 00007fb94400d300
  \[726.331687\] RBP: 00007fb943ffad00 R08: 0000000000000000 R09: 0000000000000000
  \[726.331688\] R10: 0000000000000031 R11: 0000000000000246 R12: 00007fb943ffb000
  \[726.331690\] R13: 00007fb943ffb040 R14: 0000000000000000 R15: 00007fb943ffd260
  \[726.331693\]  \</TASK\>

While we debug the issue, we found running fstests generic/551 on 5GB
non-zoned null\_blk device in the emulated zoned mode also had a
similar hung issue.

Also, we can reproduce the same symptom with an error injected
cow\_file\_range() setup.

The hang occurs when cow\_file\_range() fails in the middle of
allocation. cow\_file\_range() called from do\_allocation\_zoned() can
split the give region (\[start, end\]) for allocation depending on
current block group usages. When btrfs can allocate bytes for one part
of the split regions but fails for the other region (e.g. because of
-ENOSPC), we return the error leaving the pages in the succeeded regions
locked. Technically, this occurs only when @unlock == 0. Otherwise, we
unlock the pages in an allocated region after creating an ordered
extent.

Considering the callers of cow\_file\_range(unlock=0) won't write out
the pages, we can unlock the pages on error exit from
cow\_file\_range(). So, we can ensure all the pages except @locked\_page
are unlocked on error case.

In summary, cow\_file\_range now behaves like this:

- page\_started == 1 (return value)
  - All the pages are unlocked. IO is started.
- unlock == 1
  - All the pages except @locked\_page are unlocked in any case
- unlock == 0
  - On success, all the pages are locked for writing out them
  - On failure, all the pages except @locked\_page are unlocked

## Affected and fixed versions

- Linux: \>= 42c011000963442ce533d92a492c4a057b2f5a46, \< b367f125c80fa838eae49e3b138dc67dfc9f46ef; \>= 42c011000963442ce533d92a492c4a057b2f5a46, \< 9535ec371d741fa037e37eddc0a5b25ba82d0027; \>= 42c011000963442ce533d92a492c4a057b2f5a46, \< e160aa87c87a9c4e0c8d1430235f715a3a91e2cd; \>= 42c011000963442ce533d92a492c4a057b2f5a46, \< 9ce7466f372d83054c7494f6b3e4b9abaf3f0355 (cvelist)
- Linux: 5.12 (cvelist)

## Mitigation

- Upgrade Linux to 9ce7466f372d83054c7494f6b3e4b9abaf3f0355 or later.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2022-50089.md
Affected: Linux >= 42c011000963442ce533d92a492c4a057b2f5a46, < b367f125c80fa838eae49e3b138dc67dfc9f46ef; >= 42c011000963442ce533d92a492c4a057b2f5a46, < 9535ec371d741fa037e37eddc0a5b25ba82d0027; >= 42c011000963442ce533d92a492c4a057b2f5a46, < e160aa87c87a9c4e0c8d1430235f715a3a91e2cd; >= 42c011000963442ce533d92…
Fixed in: Linux 9535ec371d741fa037e37eddc0a5b25ba82d0027, Linux 9ce7466f372d83054c7494f6b3e4b9abaf3f0355

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-2022-50089 being exploited?

There is no confirmed exploitation: CVE-2022-50089 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-26).

### How serious is CVE-2022-50089?

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

### Which versions are affected by CVE-2022-50089?

Linux \>= 42c011000963442ce533d92a492c4a057b2f5a46, \< b367f125c80fa838eae49e3b138dc67dfc9f46ef; \>= 42c011000963442ce533d92a492c4a057b2f5a46, \< 9535ec371d741fa037e37eddc0a5b25ba82d0027; \>= 42c011000963442ce533d92a492c4a057b2f5a46, \< e160aa87c87a9c4e0c8d1430235f715a3a91e2cd; \>= 42c011000963442ce533d92a492c4a057b2f5a46, \< 9ce7466f372d83054c7494f6b3e4b9abaf3f0355; Linux 5.12.

### Is there a fix for CVE-2022-50089?

Yes. Fixed in Linux 9535ec371d741fa037e37eddc0a5b25ba82d0027, Linux 9ce7466f372d83054c7494f6b3e4b9abaf3f0355. Upgrade Linux to 9ce7466f372d83054c7494f6b3e4b9abaf3f0355 or later.

### How do I check if I'm affected by CVE-2022-50089?

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/b367f125c80fa838eae49e3b138dc67dfc9f46ef>
- patch: <https://git.kernel.org/stable/c/9535ec371d741fa037e37eddc0a5b25ba82d0027>
- patch: <https://git.kernel.org/stable/c/e160aa87c87a9c4e0c8d1430235f715a3a91e2cd>
- patch: <https://git.kernel.org/stable/c/9ce7466f372d83054c7494f6b3e4b9abaf3f0355>

## 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-2022-50089>

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