CVE-2022-50089: btrfs: ensure pages are unlocked on cow_file_range() failure

Published Jun 18, 2025
·
Updated

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

btrfs: ensure pages are unlocked on cowfilerange() failure

There is a hungtask 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/hungtasktimeoutsecs" 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] ioschedule+0x3f/0x70 [726.331629] foliolock+0x125/0x200 [726.331634] ? findgetentries+0x1bc/0x240 [726.331638] ? filemapinvalidateunlocktwo+0x40/0x40 [726.331642] truncateinodepagesrange+0x5b2/0x770 [726.331649] truncateinodepagesfinal+0x44/0x50 [726.331653] btrfsevictinode+0x67/0x480 [726.331658] evict+0xd0/0x180 [726.331661] iput+0x13f/0x200 [726.331664] dounlinkat+0x1c0/0x2b0 [726.331668] x64sysunlink+0x23/0x30 [726.331670] dosyscall64+0x3b/0xc0 [726.331674] entrySYSCALL64afterhwframe+0x44/0xae [726.331677] RIP: 0033:0x7fb9490a171b [726.331681] RSP: 002b:00007fb943ffac68 EFLAGS: 00000246 ORIGRAX: 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 nullblk device in the emulated zoned mode also had a similar hung issue.

Also, we can reproduce the same symptom with an error injected cowfilerange() setup.

The hang occurs when cowfilerange() fails in the middle of allocation. cowfilerange() called from doallocationzoned() 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 cowfilerange(unlock=0) won't write out the pages, we can unlock the pages on error exit from cowfilerange(). So, we can ensure all the pages except @lockedpage are unlocked on error case.

In summary, cowfilerange now behaves like this:

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

Affected Software

4 affected components
Linux Kernel
Linux Linux kernel>=5.12<5.15.61
Linux Linux kernel>=5.16<5.18.18
Linux Linux kernel>=5.19<5.19.2

Event History

Jun 18, 2025
CVE Published
via MITRE·11:02 AM
Data Sourced
via MITRE·11:02 AM
Description
Data Sourced
via NVD·11:15 AM
RemedyDescriptionSeverityAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2022-50089?

CVE-2022-50089 is classified as a moderate severity vulnerability in the Linux kernel.

2

How do I fix CVE-2022-50089?

To remediate CVE-2022-50089, update to the latest stable version of the Linux kernel that includes the fix.

3

What are the potential impacts of CVE-2022-50089?

CVE-2022-50089 could lead to system hang or reduced performance due to blocked tasks in zoned btrfs volumes.

4

Which versions of the Linux kernel are affected by CVE-2022-50089?

CVE-2022-50089 affects various versions of the Linux kernel prior to the resolution of the vulnerability.

5

Is there a workaround for CVE-2022-50089?

There are no specific workarounds for CVE-2022-50089; however, updating the kernel is the recommended approach to avoid the issue.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203