CVE-2026-143241: btrfs: zoned: don't wait for ordered extents in do_zone_finish()
In the Linux kernel, the following vulnerability has been resolved:
btrfs: zoned: don't wait for ordered extents in dozonefinish()
dozonefinish() calls btrfswaitorderedroots(), which holds fsinfo->orderedoperationsmutex while waiting for writeback. It can be reached from writeback itself:
cowfilerange() -> btrfsreserveextent() -> findfreeextent() -> btrfszonefinishonebg() -> dozonefinish()
If another task holds the mutex and waits for that writeback, this deadlocks.
In general, we want to ensure all writes in the block group to complete before finishing the zone, as relocation does. However, the current callers do not need the wait (or cannot wait) in dozonefinish():
- Relocation already waits for reservations and ordered extents itself before calling btrfszonefinish(). - btrfsdeleteunusedbgs() checks that ->reserved is zero and sets the block group read-only while holding groupssem, so there can be no in-flight data write. - btrfszonefinishonebg() is called from the allocation path and cannot wait.
Dropping the wait is still safe. Once the block group is read-only, ->reserved can only drop, and for data it only drops after the ordered extent's I/O has completed. So if ->reserved is zero, no data write is left in flight. If it is non-zero, dozonefinish() returns -EAGAIN, which all callers handle.
This makes btrfszonefinishonebg() fail with -EAGAIN when it races with an allocation in the selected block group.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.19 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.20 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.120 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.66 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.7 - Compensating control
In Btrfs zoned code, remove the ordered-extents wait (`btrfs_wait_ordered_roots()`) from `do_zone_finish()`.
Event History
Frequently Asked Questions
Which systems are exposed to this deadlock?
The issue is in the Btrfs zoned filesystem code in the Linux kernel. It can occur when zone finishing is reached from the allocation/writeback path, including a path that begins in cow_file_range() and proceeds through extent reservation and free-extent selection.
What conditions trigger the deadlock?
The deadlock requires do_zone_finish() to wait for ordered extents while holding fs_info->ordered_operations_mutex, and writeback to re-enter that path. If another task holds the mutex while waiting for the same writeback, neither task can proceed.
Which zone-finishing callers are relevant when assessing impact?
The described callers are relocation, deletion of unused block groups, and btrfs_zone_finish_one_bg() from the allocation path. Relocation already waits for reservations and ordered extents before zone finishing, while the allocation path cannot safely wait.
What does the fix change?
The fix removes the ordered-extent wait from do_zone_finish(). The description states this remains safe because once a block group is read-only, its reserved count can only decrease, and data reservations decrease only after the associated ordered extent completes.