Bug 2212513 (CVE-2023-3111) - CVE-2023-3111 kernel: Use after free in prepare_to_relocate in fs/btrfs/relocation.c
Summary: CVE-2023-3111 kernel: Use after free in prepare_to_relocate in fs/btrfs/reloc...
Keywords:
Status: CLOSED WONTFIX
Alias: CVE-2023-3111
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 2212347
TreeView+ depends on / blocked
 
Reported: 2023-06-05 18:51 UTC by Rohit Keshri
Modified: 2023-08-22 07:41 UTC (History)
44 users (show)

Fixed In Version: Kernel 6.0-rc2
Doc Type: If docs needed, set a value
Doc Text:
A use-after-free flaw was found in prepare_to_relocate in fs/btrfs/relocation.c in btrfs in the Linux Kernel. This issue can be triggered by calling btrfs_ioctl_balance() before calling btrfs_ioctl_defrag().
Clone Of:
Environment:
Last Closed: 2023-06-06 00:32:12 UTC
Embargoed:


Attachments (Terms of Use)

Description Rohit Keshri 2023-06-05 18:51:17 UTC
In btrfs_relocate_block_group(), the structure variable rc is allocated. Then btrfs_relocate_block_group() calls relocate_block_group() -> prepare_to_relocate() -> set_reloc_control(), and 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. 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().

Refer:
https://patchwork.kernel.org/project/linux-btrfs/patch/20220721074829.2905233-1-r33s3n6@gmail.com/

Comment 3 Product Security DevOps Team 2023-06-06 00:32:08 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2023-3111


Note You need to log in before you can comment on or make changes to this bug.