CVE-2024-49868 Information
Description
In the Linux kernel the following vulnerability has been resolved:
btrfs: fix a NULL pointer dereference when failed to start a new trasacntion
[BUG] Syzbot reported a NULL pointer dereference with the following crash:
FAULT_INJECTION: forcing a failure.
start_transaction+0x830/0x1670 fs/btrfs/transaction.c:676
prepare_to_relocate+0x31f/0x4c0 fs/btrfs/relocation.c:3642
relocate_block_group+0x169/0xd20 fs/btrfs/relocation.c:3678
…
BTRFS info (device loop0): balance: ended with status: -12
Oops: general protection fault probably for non-canonical address 0xdffffc00000000cc: 0000 [1] PREEMPT SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000660-0x0000000000000667]
RIP: 0010:btrfs_update_reloc_root+0x362/0xa80 fs/btrfs/relocation.c:926
Call Trace:
[CAUSE] The allocation failure happens at the start_transaction() inside prepare_to_relocate() and during the error handling we call unset_reloc_control() which makes fs_info->balance_ctl to be NULL.
Then we continue the error path cleanup in btrfs_balance() by calling reset_balance_state() which will call del_balance_item() to fully delete the balance item in the root tree.
However during the small window between set_reloc_contrl() and unset_reloc_control() we can have a subvolume tree update and created a reloc_root for that subvolume.
Then we go into the final btrfs_commit_transaction() of del_balance_item() and into btrfs_update_reloc_root() inside commit_fs_roots().
That function checks if fs_info->reloc_ctl is in the merge_reloc_tree stage but since fs_info->reloc_ctl is NULL it results a NULL pointer dereference.
[FIX] Just add extra check on fs_info->reloc_ctl inside btrfs_update_reloc_root() before checking fs_info->reloc_ctl->merge_reloc_tree.
That DEAD_RELOC_TREE handling is to prevent further modification to the reloc tree during merge stage but since there is no reloc_ctl at all we do not need to bother that.
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
Reference
https://git.kernel.org/stable/c/d73d48acf36f57362df7e4f9d76568168bf5e944 https://git.kernel.org/stable/c/37fee9c220b92c3b7bf22b51c51dde5364e7590b https://git.kernel.org/stable/c/d13249c0df7aab885acb149695f82c54c0822a70 https://git.kernel.org/stable/c/7ad0c5868f2f0418619089513d95230c66cb7eb4 https://git.kernel.org/stable/c/dc02c1440705e3451abd1c2c8114a5c1bb188e9f https://git.kernel.org/stable/c/39356ec0e319ed07627b3a0f402d0608546509e6 https://git.kernel.org/stable/c/c3b47f49e83197e8dffd023ec568403bcdbb774b
Attack Complexity
LOW
Privileges Required
LOW
User Interaction Required
LOW
Scope
NONE
Confidentiality Impact
UNCHANGED
Integrity Impact
NONE
Availability Impact
NONE
Base Score
HIGH
Base Severity
5.5
Share on: