CVE-2023-52707

Severity CVSS v4.0:
Pending analysis
Type:
CWE-416 Use After Free
Publication date:
21/05/2024
Last modified:
06/01/2025

Description

In the Linux kernel, the following vulnerability has been resolved:<br /> <br /> sched/psi: Fix use-after-free in ep_remove_wait_queue()<br /> <br /> If a non-root cgroup gets removed when there is a thread that registered<br /> trigger and is polling on a pressure file within the cgroup, the polling<br /> waitqueue gets freed in the following path:<br /> <br /> do_rmdir<br /> cgroup_rmdir<br /> kernfs_drain_open_files<br /> cgroup_file_release<br /> cgroup_pressure_release<br /> psi_trigger_destroy<br /> <br /> However, the polling thread still has a reference to the pressure file and<br /> will access the freed waitqueue when the file is closed or upon exit:<br /> <br /> fput<br /> ep_eventpoll_release<br /> ep_free<br /> ep_remove_wait_queue<br /> remove_wait_queue<br /> <br /> This results in use-after-free as pasted below.<br /> <br /> The fundamental problem here is that cgroup_file_release() (and<br /> consequently waitqueue&amp;#39;s lifetime) is not tied to the file&amp;#39;s real lifetime.<br /> Using wake_up_pollfree() here might be less than ideal, but it is in line<br /> with the comment at commit 42288cb44c4b ("wait: add wake_up_pollfree()")<br /> since the waitqueue&amp;#39;s lifetime is not tied to file&amp;#39;s one and can be<br /> considered as another special case. While this would be fixable by somehow<br /> making cgroup_file_release() be tied to the fput(), it would require<br /> sizable refactoring at cgroups or higher layer which might be more<br /> justifiable if we identify more cases like this.<br /> <br /> BUG: KASAN: use-after-free in _raw_spin_lock_irqsave+0x60/0xc0<br /> Write of size 4 at addr ffff88810e625328 by task a.out/4404<br /> <br /> CPU: 19 PID: 4404 Comm: a.out Not tainted 6.2.0-rc6 #38<br /> Hardware name: Amazon EC2 c5a.8xlarge/, BIOS 1.0 10/16/2017<br /> Call Trace:<br /> <br /> dump_stack_lvl+0x73/0xa0<br /> print_report+0x16c/0x4e0<br /> kasan_report+0xc3/0xf0<br /> kasan_check_range+0x2d2/0x310<br /> _raw_spin_lock_irqsave+0x60/0xc0<br /> remove_wait_queue+0x1a/0xa0<br /> ep_free+0x12c/0x170<br /> ep_eventpoll_release+0x26/0x30<br /> __fput+0x202/0x400<br /> task_work_run+0x11d/0x170<br /> do_exit+0x495/0x1130<br /> do_group_exit+0x100/0x100<br /> get_signal+0xd67/0xde0<br /> arch_do_signal_or_restart+0x2a/0x2b0<br /> exit_to_user_mode_prepare+0x94/0x100<br /> syscall_exit_to_user_mode+0x20/0x40<br /> do_syscall_64+0x52/0x90<br /> entry_SYSCALL_64_after_hwframe+0x63/0xcd<br /> <br /> <br /> Allocated by task 4404:<br /> <br /> kasan_set_track+0x3d/0x60<br /> __kasan_kmalloc+0x85/0x90<br /> psi_trigger_create+0x113/0x3e0<br /> pressure_write+0x146/0x2e0<br /> cgroup_file_write+0x11c/0x250<br /> kernfs_fop_write_iter+0x186/0x220<br /> vfs_write+0x3d8/0x5c0<br /> ksys_write+0x90/0x110<br /> do_syscall_64+0x43/0x90<br /> entry_SYSCALL_64_after_hwframe+0x63/0xcd<br /> <br /> Freed by task 4407:<br /> <br /> kasan_set_track+0x3d/0x60<br /> kasan_save_free_info+0x27/0x40<br /> ____kasan_slab_free+0x11d/0x170<br /> slab_free_freelist_hook+0x87/0x150<br /> __kmem_cache_free+0xcb/0x180<br /> psi_trigger_destroy+0x2e8/0x310<br /> cgroup_file_release+0x4f/0xb0<br /> kernfs_drain_open_files+0x165/0x1f0<br /> kernfs_drain+0x162/0x1a0<br /> __kernfs_remove+0x1fb/0x310<br /> kernfs_remove_by_name_ns+0x95/0xe0<br /> cgroup_addrm_files+0x67f/0x700<br /> cgroup_destroy_locked+0x283/0x3c0<br /> cgroup_rmdir+0x29/0x100<br /> kernfs_iop_rmdir+0xd1/0x140<br /> vfs_rmdir+0xfe/0x240<br /> do_rmdir+0x13d/0x280<br /> __x64_sys_rmdir+0x2c/0x30<br /> do_syscall_64+0x43/0x90<br /> entry_SYSCALL_64_after_hwframe+0x63/0xcd

Vulnerable products and versions

CPE From Up to
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.2 (including) 5.4.232 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.5 (including) 5.10.169 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.11 (including) 5.15.95 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.16 (including) 6.1.13 (excluding)
cpe:2.3:o:linux:linux_kernel:6.2:rc1:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.2:rc2:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.2:rc3:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.2:rc4:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.2:rc5:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.2:rc6:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.2:rc7:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.2:rc8:*:*:*:*:*:*