btrfs: unset reloc control if transaction commit fails in prepare_to_relocate()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ fb686c6824dd6294ca772b92424b8fba666e7d00 · < 5d741afed0bac206640cc64d77b97853283cf719| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
btrfs: unset reloc control if transaction commit fails in prepare_to_relocate()
In btrfs_relocate_block_group(), the rc is allocated. Then btrfs_relocate_block_group() calls
relocate_block_group() prepare_to_relocate() set_reloc_control()
that assigns rc to the variable fs_info->reloc_ctl. When prepare_to_relocate() returns, it calls
btrfs_commit_transaction() btrfs_start_dirty_block_groups() btrfs_alloc_path() kmem_cache_zalloc()
which may fail for example (or other errors could happen). When the failure occurs, btrfs_relocate_block_group() detects the error and frees rc and doesn't set fs_info->reloc_ctl to NULL. After that, in btrfs_init_reloc_root(), rc is retrieved from fs_info->reloc_ctl and then used, which may cause a use-after-free bug.
This possible bug can be triggered by calling btrfs_ioctl_balance() before calling btrfs_ioctl_defrag().
From the CVE record · Linux
The Linux kernel's btrfs relocation code can retain a pointer to freed memory if a transaction commit fails. A local caller may trigger a use-after-free by invoking the btrfs balance ioctl before the defrag ioctl under that failure condition; the input does not specify authentication requirements.
Engineers running Linux kernels with btrfs should check their installations; affected versions are not specified.