Vulnerability · Published Apr 16, 2025 · Assigned by Linux
CVE-2025-22115btrfs: fix block group refcount race in btrfs_create_pending_block_groups()
High 7.8
In plain English
A high-severity security flaw in Linux from Linux. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 0.2% (higher than 7% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.
Official description
In the Linux kernel, the following vulnerability has been resolved: btrfs: fix block group refcount race in btrfs_create_pending_block_groups() Block group creation is done in two phases, which results in a slightly unintuitive property: a block group can be allocated/deallocated from after btrfs_make_block_group() adds it to the space_info with btrfs_add_bg_to_space_info(), but before creation is completely completed in btrfs_create_pending_block_groups(). As a result, it is possible for a block group to go unused and have 'btrfs_mark_bg_unused' called on it concurrently with 'btrfs_create_pending_block_groups'. This causes a number of issues, which were fixed with the block group flag 'BLOCK_GROUP_FLAG_NEW'. However, this fix is not quite complete. Since it does not use the unused_bg_lock, it is possible for the following race to occur: btrfs_create_pending_block_groups btrfs_mark_bg_unused if list_empty // false list_del_init clear_bit else if (test_bit) // true list_move_tail And we get into the exact same broken ref count and invalid new_bgs state for transaction cleanup that BLOCK_GROUP_FLAG_NEW was designed to prevent. The broken refcount aspect will result in a warning like: [1272.943527] refcount_t: underflow; use-after-free. [1272.943967] WARNING: CPU: 1 PID: 61 at lib/refcount.c:28 refcount_warn_saturate+0xba/0x110 [1272.944731] Modules linked in: btrfs virtio_net xor zstd_compress raid6_pq null_blk [last unloaded: btrfs] [1272.945550] CPU: 1 UID: 0 PID: 61 Comm: kworker/u32:1 Kdump: loaded Tainted: G W 6.14.0-rc5+ #108 [1272.946368] Tainted: [W]=WARN [1272.946585] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Arch Linux 1.16.3-1-1 04/01/2014 [1272.947273] Workqueue: btrfs_discard btrfs_discard_workfn [btrfs] [1272.947788] RIP: 0010:refcount_warn_saturate+0xba/0x110 [1272.949532] RSP: 0018:ffffbf1200247df0 EFLAGS: 00010282 [1272.949901] RAX: 0000000000000000 RBX: ffffa14b00e3f800 RCX: 0000000000000000 [1272.950437] RDX: 0000000000000000 RSI: ffffbf1200247c78 RDI: 00000000ffffdfff [1272.950986] RBP: ffffa14b00dc2860 R08: 00000000ffffdfff R09: ffffffff90526268 [1272.951512] R10: ffffffff904762c0 R11: 0000000063666572 R12: ffffa14b00dc28c0 [1272.952024] R13: 0000000000000000 R14: ffffa14b00dc2868 R15: 000001285dcd12c0 [1272.952850] FS: 0000000000000000(0000) GS:ffffa14d33c40000(0000) knlGS:0000000000000000 [1272.953458] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [1272.953931] CR2: 00007f838cbda000 CR3: 000000010104e000 CR4: 00000000000006f0 [1272.954474] Call Trace: [1272.954655] <TASK> [1272.954812] ? refcount_warn_saturate+0xba/0x110 [1272.955173] ? __warn.cold+0x93/0xd7 [1272.955487] ? refcount_warn_saturate+0xba/0x110 [1272.955816] ? report_bug+0xe7/0x120 [1272.956103] ? handle_bug+0x53/0x90 [1272.956424] ? exc_invalid_op+0x13/0x60 [1272.956700] ? asm_exc_invalid_op+0x16/0x20 [1272.957011] ? refcount_warn_saturate+0xba/0x110 [1272.957399] btrfs_discard_cancel_work.cold+0x26/0x2b [btrfs] [1272.957853] btrfs_put_block_group.cold+0x5d/0x8e [btrfs] [1272.958289] btrfs_discard_workfn+0x194/0x380 [btrfs] [1272.958729] process_one_work+0x130/0x290 [1272.959026] worker_thread+0x2ea/0x420 [1272.959335] ? __pfx_worker_thread+0x10/0x10 [1272.959644] kthread+0xd7/0x1c0 [1272.959872] ? __pfx_kthread+0x10/0x10 [1272.960172] ret_from_fork+0x30/0x50 [1272.960474] ? __pfx_kthread+0x10/0x10 [1272.960745] ret_from_fork_asm+0x1a/0x30 [1272.961035] </TASK> [1272.961238] ---[ end trace 0000000000000000 ]--- Though we have seen them in the async discard workfn as well. It is most likely to happen after a relocation finishes which cancels discard, tears down the block group, etc. Fix this fully by taking the lock arou ---truncated---
Affected packages & fixed versions
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian:12 | linux | no fix listed | DEBIAN-CVE-2025-22115 |
| Debian:13 | linux | 6.12.41-1 | DSA-5975-1 |
| Debian:13 | linux | 6.12.41-1 | DEBIAN-CVE-2025-22115 |
| Debian:14 | linux | 6.16.3-1 | DEBIAN-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux | 6.8.0-100.100 | USN-8028-1 |
| Ubuntu:24.04:LTS | linux | 6.8.0-100.100 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-allwinner-5.19 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-aws | 6.8.0-1046.49 | USN-8028-5 |
| Ubuntu:24.04:LTS | linux-aws | 6.8.0-1046.49 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-aws-5.19 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-aws-6.2 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-aws-6.5 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-aws-6.8 | 6.8.0-1046.49~22.04.1 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-aws-6.8 | 6.8.0-1046.49~22.04.1 | USN-8028-5 |
| Ubuntu:24.04:LTS | linux-azure | 6.8.0-1046.52 | USN-8074-1 |
| Ubuntu:24.04:LTS | linux-azure | 6.8.0-1046.52 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-azure-5.19 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-azure-6.11 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-azure-6.2 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-azure-6.5 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-azure-6.8 | 6.8.0-1051.57~22.04.1 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-azure-6.8 | 6.8.0-1051.57~22.04.1 | USN-8126-1 |
| Ubuntu:24.04:LTS | linux-azure-fde | 6.8.0-1046.53 | UBUNTU-CVE-2025-22115 |
| Ubuntu:25.10 | linux-azure-fde | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-azure-fde-5.19 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-azure-fde-6.2 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-azure-fde-6.8 | 6.8.0-1046.53~22.04.1 | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-azure-nvidia | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-gcp | 6.8.0-1047.50 | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-gcp | 6.8.0-1047.50 | USN-8031-3 |
| Ubuntu:22.04:LTS | linux-gcp-5.19 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-gcp-6.11 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-gcp-6.2 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-gcp-6.5 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-gcp-6.8 | 6.8.0-1047.50~22.04.2 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-gcp-6.8 | 6.8.0-1047.50~22.04.2 | USN-8031-1 |
| Ubuntu:24.04:LTS | linux-gke | 6.8.0-1043.48 | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-gke | 6.8.0-1043.48 | USN-8031-3 |
| Ubuntu:24.04:LTS | linux-gkeop | 6.8.0-1030.33 | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-gkeop | 6.8.0-1030.33 | USN-8028-5 |
| Ubuntu:22.04:LTS | linux-hwe-5.19 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-hwe-6.11 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-hwe-6.2 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-hwe-6.5 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-hwe-6.8 | 6.8.0-100.100~22.04.1 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-hwe-6.8 | 6.8.0-100.100~22.04.1 | USN-8028-6 |
| Ubuntu:24.04:LTS | linux-ibm | 6.8.0-1044.44 | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-ibm | 6.8.0-1044.44 | USN-8028-8 |
| Ubuntu:22.04:LTS | linux-ibm-6.8 | 6.8.0-1044.44~22.04.1 | USN-8028-8 |
| Ubuntu:22.04:LTS | linux-ibm-6.8 | 6.8.0-1044.44~22.04.1 | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-intel | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-intel-iot-realtime | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-lowlatency | 6.8.0-100.100.1 | USN-8052-1 |
| Ubuntu:24.04:LTS | linux-lowlatency | 6.8.0-100.100.1 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-5.19 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-lowlatency-hwe-6.11 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.2 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.5 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.8 | 6.8.0-100.100.1~22.04.1 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.8 | 6.8.0-100.100.1~22.04.1 | USN-8028-6 |
| Ubuntu:24.04:LTS | linux-nvidia | 6.8.0-1046.49 | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-nvidia | 6.8.0-1046.49 | USN-8028-5 |
| Ubuntu:24.04:LTS | linux-nvidia-6.11 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-nvidia-6.2 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-nvidia-6.5 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-nvidia-6.8 | 6.8.0-1046.49~22.04.1 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-nvidia-6.8 | 6.8.0-1046.49~22.04.1 | USN-8028-5 |
| Ubuntu:24.04:LTS | linux-nvidia-lowlatency | 6.8.0-1046.49.1 | USN-8028-7 |
| Ubuntu:24.04:LTS | linux-nvidia-lowlatency | 6.8.0-1046.49.1 | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-nvidia-tegra | 6.8.0-1020.20 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-oem-5.17 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-oem-6.0 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-oem-6.1 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-oem-6.11 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-oem-6.5 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-oem-6.8 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-oracle | 6.8.0-1043.44 | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-oracle | 6.8.0-1043.44 | USN-8028-5 |
| Ubuntu:22.04:LTS | linux-oracle-6.5 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-oracle-6.8 | 6.8.0-1043.44~22.04.1 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-oracle-6.8 | 6.8.0-1043.44~22.04.1 | USN-8028-5 |
| Ubuntu:24.04:LTS | linux-raspi | 6.8.0-1047.51 | USN-8028-1 |
| Ubuntu:24.04:LTS | linux-raspi | 6.8.0-1047.51 | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-raspi-realtime | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-realtime | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-realtime | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-riscv | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-riscv | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-riscv-5.19 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-riscv-6.5 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-riscv-6.8 | 6.8.0-100.100~22.04.1 | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-starfive-5.19 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-starfive-6.2 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:22.04:LTS | linux-starfive-6.5 | no fix listed | UBUNTU-CVE-2025-22115 |
| Ubuntu:24.04:LTS | linux-xilinx | 6.8.0-1023.24 | USN-8052-2 |
| Ubuntu:24.04:LTS | linux-xilinx | 6.8.0-1023.24 | UBUNTU-CVE-2025-22115 |
Affected products (as reported)
| Vendor | Product | Versions |
|---|---|---|
| Linux | Linux | 6297644db23f77c02ae7961cc542d162629ae2c4 – before 3232bdf8a135877345c25bf4c0d892334a4c03f70657b20c5a76c938612f8409735a8830d257866e – before 77fd40b7ed0c3acf989a0f2a07b15a0a59ea8f960657b20c5a76c938612f8409735a8830d257866e – before ee56da95f8962b86fec4ef93f866e64c8d025a580657b20c5a76c938612f8409735a8830d257866e – before 9d383a6fc59271aaaf07a33b23b2eac5b9268b7a0657b20c5a76c938612f8409735a8830d257866e – before 2d8e5168d48a91e7a802d3003e72afb4304bebfa7569c4294ba6ff9f194635b14876198f8a687c4a6.1.47 – before 6.1.1916.4.12 – before 6.5 |
| Linux | Linux | 6.5 |
References
- https://git.kernel.org/stable/c/3232bdf8a135877345c25bf4c0d892334a4c03f7
- https://git.kernel.org/stable/c/77fd40b7ed0c3acf989a0f2a07b15a0a59ea8f96
- https://git.kernel.org/stable/c/ee56da95f8962b86fec4ef93f866e64c8d025a58
- https://git.kernel.org/stable/c/9d383a6fc59271aaaf07a33b23b2eac5b9268b7a
- https://git.kernel.org/stable/c/2d8e5168d48a91e7a802d3003e72afb4304bebfa