In the Linux kernel, the following vulnerability has been resolved:
btrfs: fix space cache corruption and potential double allocations
When testing space_cache v2 on a large set of machines, we encountered a few symptoms:
All of these symptoms have the same underlying cause: a race between caching the free space for a block group and returning free space to the in-memory space cache for pinned extents causes us to double-add a free range to the space cache. This race exists when free space is cached from the free space tree (space_cache=v2) or the extent tree (nospace_cache, or space_cache=v1 if the cache needs to be regenerated). struct btrfs_block_group::last_byte_to_unpin and struct btrfs_block_group::progress are supposed to protect against this race, but commit d0c2f4fa555e ("btrfs: make concurrent fsyncs wait less when waiting for a transaction commit") subtly broke this by allowing multiple transactions to be unpinning extents at the same time.
Specifically, the race is as follows:
This explains all of our symptoms above:
| Software | From | Fixed in |
|---|---|---|
| linux / linux_kernel | 5.12 | 5.15.65 |
| linux / linux_kernel | 5.16 | 5.19.6 |
| linux / linux_kernel | 6.0-rc1 | 6.0-rc1.x |
| linux / linux_kernel | 6.0-rc2 | 6.0-rc2.x |