CVE-2025-21942 Information
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
cho 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:
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 (trfs: 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.
Reference
https://git.kernel.org/stable/c/3fcff2f55389306482ab049b4321bda49495e546 https://git.kernel.org/stable/c/5a4041f2c47247575a6c2e53ce14f7b0ac946c33
Share on: