In the Linux kernel, the following vulnerability has been resolved:
btrfs: fix transaction use-after-free in raid stripe insertion
If allocation of a RAID stripe extent fails,
btrfs_insert_one_raid_extent() aborts and ends the transaction before
returning -ENOMEM.
btrfs_finish_one_ordered(), the production caller through
btrfs_insert_raid_extent(), still owns the transaction handle. It handles
the error by aborting the transaction and then reaches the common exit
path, which ends the transaction again.
The premature end can free the handle and drop its transaction reference.
Transaction cleanup can then free the transaction before the caller's
second abort accesses the handle and transaction, resulting in
use-after-free.
Keep the abort at the failure site, but let the caller's common exit path
end the transaction once, after it has finished using both objects.
CVSS Vector: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H
CVSS Score: 7
AV:L - The bug is reached through local file writes: buffered or direct writes on a mounted btrfs raid-stripe-tree filesystem create ordered extents, and btrfs_finish_one_ordered() then calls btrfs_insert_raid_extent() -> btrfs_insert_one_raid_extent(). No remote peer supplies input that causes the failure.
AC:H - The bug fires only when a small, non-memcg-accounted kzalloc(GFP_NOFS) of the stripe extent fails, which needs system-wide memory exhaustion the attacker cannot reliably produce. It also needs a non-default CONFIG_BTRFS_EXPERIMENTAL kernel and an admin-created RAID_STRIPE_TREE filesystem.
PR:L - Once such a filesystem is mounted, any unprivileged user with write access to a file on it can drive ordered extent completion into btrfs_insert_one_raid_extent(). No capability check exists on this path.
UI:N - The attacker only issues their own write operations to a filesystem that is already mounted; no mounting of attacker media or other victim action is needed.
S:U - The corrupted objects are kernel btrfs_trans_handle and btrfs_transaction structures in the same kernel security authority; no VM, IOMMU or sandbox boundary is crossed.
C:H - After the premature btrfs_end_transaction() frees the trans handle and drops the transaction reference, btrfs_finish_one_ordered() aborts on the freed handle and transaction. That use-after-free of slab objects could be reclaimed by attacker-sprayed data to leak kernel memory.
I:H - The caller's btrfs_abort_transaction() writes to the freed handle and transaction, and its second btrfs_end_transaction() frees the handle again. This use-after-write and double free of slab objects is a memory-corruption primitive usable for control-flow hijack.
A:H - The double end/free of the btrfs transaction handle and use of the freed transaction reliably corrupts slab state or oopses the kernel, taking down the system and the filesystem.
| Attack Vector |
Local |
Scope |
Unchanged |
| Attack Complexity |
High |
Confidentiality Impact |
High |
| Privileges Required |
Low |
Integrity Impact |
High |
| User Interaction |
None |
Availability Impact |
High |
AV:L - The bug is reached through local file writes: buffered or direct writes on a mounted btrfs raid-stripe-tree filesystem create ordered extents, and btrfs_finish_one_ordered() then calls btrfs_insert_raid_extent() -> btrfs_insert_one_raid_extent(). No remote peer supplies input that causes the failure.
AC:H - The bug fires only when a small, non-memcg-accounted kzalloc(GFP_NOFS) of the stripe extent fails, which needs system-wide memory exhaustion the attacker cannot reliably produce. It also needs a non-default CONFIG_BTRFS_EXPERIMENTAL kernel and an admin-created RAID_STRIPE_TREE filesystem.
PR:L - Once such a filesystem is mounted, any unprivileged user with write access to a file on it can drive ordered extent completion into btrfs_insert_one_raid_extent(). No capability check exists on this path.
UI:N - The attacker only issues their own write operations to a filesystem that is already mounted; no mounting of attacker media or other victim action is needed.
S:U - The corrupted objects are kernel btrfs_trans_handle and btrfs_transaction structures in the same kernel security authority; no VM, IOMMU or sandbox boundary is crossed.
C:H - After the premature btrfs_end_transaction() frees the trans handle and drops the transaction reference, btrfs_finish_one_ordered() aborts on the freed handle and transaction. That use-after-free of slab objects could be reclaimed by attacker-sprayed data to leak kernel memory.
I:H - The caller's btrfs_abort_transaction() writes to the freed handle and transaction, and its second btrfs_end_transaction() frees the handle again. This use-after-write and double free of slab objects is a memory-corruption primitive usable for control-flow hijack.
A:H - The double end/free of the btrfs transaction handle and use of the freed transaction reliably corrupts slab state or oopses the kernel, taking down the system and the filesystem.
CVSS 3.1