btrfs: fix block group refcount race in btrfs_create_pending_block_groups()
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: k
CVE-2025-22115
Primary source · Revision 1
Imported from structured advisory data. Source references identify upstream records or fields; verify affected versions and your deployed configuration.
Security context
Source reference: cve:CVE-2025-22115
Linux
Source reference: /containers/cna/affected/0/product
- Affected versions
- Not stated in this record
- Fixed versions
- Not stated in this record
- Prerequisites
- Not stated in this record
Linux
Source reference: /containers/cna/affected/1/product
- Affected versions
- Not stated in this record
- Fixed versions
- Not stated in this record
- Prerequisites
- Not stated in this record
Structured affected-version data
Original package identities and version rules from this source.
[
{
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"vendor": "Linux",
"product": "Linux",
"versions": [
{
"status": "affected",
"version": "0657b20c5a76c938612f8409735a8830d257866e",
"lessThan": "77fd40b7ed0c3acf989a0f2a07b15a0a59ea8f96",
"versionType": "git"
},
{
"status": "affected",
"version": "0657b20c5a76c938612f8409735a8830d257866e",
"lessThan": "ee56da95f8962b86fec4ef93f866e64c8d025a58",
"versionType": "git"
},
{
"status": "affected",
"version": "0657b20c5a76c938612f8409735a8830d257866e",
"lessThan": "9d383a6fc59271aaaf07a33b23b2eac5b9268b7a",
"versionType": "git"
},
{
"status": "affected",
"version": "0657b20c5a76c938612f8409735a8830d257866e",
"lessThan": "2d8e5168d48a91e7a802d3003e72afb4304bebfa",
"versionType": "git"
},
{
"status": "affected",
"version": "6297644db23f77c02ae7961cc542d162629ae2c4",
"versionType": "git"
},
{
"status": "affected",
"version": "7569c4294ba6ff9f194635b14876198f8a687c4a",
"versionType": "git"
},
{
"status": "affected",
"version": "6.1.47",
"lessThan": "6.2",
"versionType": "semver"
},
{
"status": "affected",
"version": "6.4.12",
"lessThan": "6.5",
"versionType": "semver"
}
],
"programFiles": [
"fs/btrfs/block-group.c"
],
"defaultStatus": "unaffected"
},
{
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"vendor": "Linux",
"product": "Linux",
"versions": [
{
"status": "affected",
"version": "6.5"
},
{
"status": "unaffected",
"version": "0",
"lessThan": "6.5",
"versionType": "semver"
},
{
"status": "unaffected",
"version": "6.6.160",
"versionType": "semver",
"lessThanOrEqual": "6.6.*"
},
{
"status": "unaffected",
"version": "6.12.40",
"versionType": "semver",
"lessThanOrEqual": "6.12.*"
},
{
"status": "unaffected",
"version": "6.14.2",
"versionType": "semver",
"lessThanOrEqual": "6.14.*"
},
{
"status": "unaffected",
"version": "6.15",
"versionType": "original_commit_for_fix",
"lessThanOrEqual": "*"
}
],
"programFiles": [
"fs/btrfs/block-group.c"
],
"defaultStatus": "affected"
}
]- Related CVEs
- CVE-2025-22115
Source reference:
/cveMetadata/cveId
Publisher severity
high
Source reference: /containers/cna/metrics
- Event
- #45961 · Revision 1
- Added to Heist Feed
- Publisher date