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 slightlyunintuitive property: a block group can be allocated/deallocated fromafter btrfs_make_block_group() adds it to the space_info withbtrfs_add_bg_to_space_info(), but before creation is completely completedin btrfs_create_pending_block_groups(). As a result, it is possible for ablock group to go unused and have 'btrfs_mark_bg_unused' called on itconcurrently with 'btrfs_create_pending_block_groups'. This causes anumber 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 theunused_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_tailAnd we get into the exact same broken ref count and invalid new_bgsstate for transaction cleanup that BLOCK_GROUP_FLAG_NEW was designed toprevent.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]
No PoCs from references.
- https://github.com/w4zu/Debian_security