Skip to content
OpenAdvisories
High · 7.8 CVE-2023-52707 EUVD-2023-57331GHSA-cw5r-8wj2-xpqf

sched/psi: Fix use-after-free in ep_remove_wait_queue()

Published May 21, 2024 · Updated Aug 5, 2026 · Assigned by Linux

Vendor: Linux Product: Linux Package: linux Package: linux Package: linux-allwinner-5.19 Package: linux-aws Package: linux-aws-5.0 Package: linux-aws-5.11 Package: linux-aws-5.13 Package: linux-aws-5.15 Package: linux-aws-5.19 Package: linux-aws-5.3 Package: linux-aws-5.4 Package: linux-aws-5.8 Package: linux-aws-6.2 Package: linux-aws-fips Package: linux-azure Package: linux-azure-5.11 Package: linux-azure-5.13 Package: linux-azure-5.15 Package: linux-azure-5.19 Package: linux-azure-5.3 Package: linux-azure-5.4 Package: linux-azure-5.8 Package: linux-azure-6.2 Package: linux-azure-edge Package: linux-azure-fde Package: linux-azure-fde-5.19 Package: linux-azure-fde-6.2 Package: linux-azure-fips Package: linux-bluefield Package: linux-fips Package: linux-gcp Package: linux-gcp-5.11 Package: linux-gcp-5.13 Package: linux-gcp-5.15 Package: linux-gcp-5.19 Package: linux-gcp-5.3 Package: linux-gcp-5.4 Package: linux-gcp-5.8 Package: linux-gcp-6.2 Package: linux-gcp-fips Package: linux-gke Package: linux-gke-4.15 Package: linux-gke-5.15 Package: linux-gke-5.4 Package: linux-gkeop Package: linux-gkeop-5.15 Package: linux-gkeop-5.4 Package: linux-hwe Package: linux-hwe-5.11 Package: linux-hwe-5.13 Package: linux-hwe-5.15 Package: linux-hwe-5.19 Package: linux-hwe-5.4 Package: linux-hwe-5.8 Package: linux-hwe-6.2 Package: linux-hwe-edge Package: linux-ibm Package: linux-ibm-5.4 Package: linux-intel-5.13 Package: linux-intel-iot-realtime Package: linux-intel-iotg Package: linux-intel-iotg-5.15 Package: linux-iot Package: linux-kvm Package: linux-lowlatency Package: linux-lowlatency-hwe-5.15 Package: linux-lowlatency-hwe-5.19 Package: linux-lowlatency-hwe-6.2 Package: linux-nvidia Package: linux-nvidia-6.2 Package: linux-nvidia-tegra-5.15 Package: linux-oem Package: linux-oem-5.10 Package: linux-oem-5.13 Package: linux-oem-5.14 Package: linux-oem-5.17 Package: linux-oem-5.6 Package: linux-oem-6.0 Package: linux-oem-6.1 Package: linux-oracle Package: linux-oracle-5.0 Package: linux-oracle-5.11 Package: linux-oracle-5.13 Package: linux-oracle-5.15 Package: linux-oracle-5.3 Package: linux-oracle-5.4 Package: linux-oracle-5.8 Package: linux-raspi Package: linux-raspi-5.4 Package: linux-raspi-realtime Package: linux-raspi2 Package: linux-realtime Package: linux-riscv Package: linux-riscv-5.11 Package: linux-riscv-5.15 Package: linux-riscv-5.19 Package: linux-riscv-5.8 Package: linux-starfive-5.19 Package: linux-starfive-6.2 Package: linux-vmware Package: linux-xilinx-zynqmp Platform: Linux Ecosystem: Debian Ecosystem: Ubuntu

Description

In the Linux kernel, the following vulnerability has been resolved:

sched/psi: Fix use-after-free in ep_remove_wait_queue()

If a non-root cgroup gets removed when there is a thread that registered
trigger and is polling on a pressure file within the cgroup, the polling
waitqueue gets freed in the following path:

do_rmdir
cgroup_rmdir
kernfs_drain_open_files
cgroup_file_release
cgroup_pressure_release
psi_trigger_destroy

However, the polling thread still has a reference to the pressure file and
will access the freed waitqueue when the file is closed or upon exit:

fput
ep_eventpoll_release
ep_free
ep_remove_wait_queue
remove_wait_queue

This results in use-after-free as pasted below.

The fundamental problem here is that cgroup_file_release() (and
consequently waitqueue's lifetime) is not tied to the file's real lifetime.
Using wake_up_pollfree() here might be less than ideal, but it is in line
with the comment at commit 42288cb44c4b ("wait: add wake_up_pollfree()")
since the waitqueue's lifetime is not tied to file's one and can be
considered as another special case. While this would be fixable by somehow
making cgroup_file_release() be tied to the fput(), it would require
sizable refactoring at cgroups or higher layer which might be more
justifiable if we identify more cases like this.

BUG: KASAN: use-after-free in _raw_spin_lock_irqsave+0x60/0xc0
Write of size 4 at addr ffff88810e625328 by task a.out/4404

CPU: 19 PID: 4404 Comm: a.out Not tainted 6.2.0-rc6 #38
Hardware name: Amazon EC2 c5a.8xlarge/, BIOS 1.0 10/16/2017
Call Trace:
<TASK>
dump_stack_lvl+0x73/0xa0
print_report+0x16c/0x4e0
kasan_report+0xc3/0xf0
kasan_check_range+0x2d2/0x310
_raw_spin_lock_irqsave+0x60/0xc0
remove_wait_queue+0x1a/0xa0
ep_free+0x12c/0x170
ep_eventpoll_release+0x26/0x30
__fput+0x202/0x400
task_work_run+0x11d/0x170
do_exit+0x495/0x1130
do_group_exit+0x100/0x100
get_signal+0xd67/0xde0
arch_do_signal_or_restart+0x2a/0x2b0
exit_to_user_mode_prepare+0x94/0x100
syscall_exit_to_user_mode+0x20/0x40
do_syscall_64+0x52/0x90
entry_SYSCALL_64_after_hwframe+0x63/0xcd
</TASK>

Allocated by task 4404:

kasan_set_track+0x3d/0x60
__kasan_kmalloc+0x85/0x90
psi_trigger_create+0x113/0x3e0
pressure_write+0x146/0x2e0
cgroup_file_write+0x11c/0x250
kernfs_fop_write_iter+0x186/0x220
vfs_write+0x3d8/0x5c0
ksys_write+0x90/0x110
do_syscall_64+0x43/0x90
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 4407:

kasan_set_track+0x3d/0x60
kasan_save_free_info+0x27/0x40
____kasan_slab_free+0x11d/0x170
slab_free_freelist_hook+0x87/0x150
__kmem_cache_free+0xcb/0x180
psi_trigger_destroy+0x2e8/0x310
cgroup_file_release+0x4f/0xb0
kernfs_drain_open_files+0x165/0x1f0
kernfs_drain+0x162/0x1a0
__kernfs_remove+0x1fb/0x310
kernfs_remove_by_name_ns+0x95/0xe0
cgroup_addrm_files+0x67f/0x700
cgroup_destroy_locked+0x283/0x3c0
cgroup_rmdir+0x29/0x100
kernfs_iop_rmdir+0xd1/0x140
vfs_rmdir+0xfe/0x240
do_rmdir+0x13d/0x280
__x64_sys_rmdir+0x2c/0x30
do_syscall_64+0x43/0x90
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Affected products

VendorProductAffectedFixed
Linux Linux 5.2 5.4.232

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 14 linux 6.1.15-1 —
Debian 13 linux 6.1.15-1 —
Debian 12 linux 6.1.15-1 —
ReleasePackageFixed inAdvisory
Ubuntu Nvidia-BlueField 22.04 LTS linux-bluefield 5.15.0-1017.19 —
Ubuntu 24.04 LTS linux-raspi-realtime No fix yet —
Ubuntu 22.04 LTS linux +1 5.15.0-72.79 —
Ubuntu 22.04 LTS linux-aws 5.15.0-1036.40 —
Ubuntu 22.04 LTS linux-azure 5.15.0-1038.45 —
Ubuntu 22.04 LTS linux-azure-fde 5.15.0-1038.45.1 —
Ubuntu 22.04 LTS linux-gcp 5.15.0-1034.42 —
Ubuntu 22.04 LTS linux-gke +1 5.15.0-1033.38 —
Ubuntu 22.04 LTS linux-gkeop 5.15.0-1020.25 —
Ubuntu 22.04 LTS linux-ibm 5.15.0-1030.33 —
Ubuntu 22.04 LTS linux-intel-iotg 5.15.0-1030.35 —
Ubuntu 22.04 LTS linux-nvidia 5.15.0-1025.25 —
Ubuntu 22.04 LTS linux-oracle 5.15.0-1035.41 —
Ubuntu 22.04 LTS linux-raspi 5.15.0-1029.31 —
Ubuntu 22.04 LTS linux-riscv +21 No fix yet —
Ubuntu 20.04 LTS linux 5.4.0-149.166 —
Ubuntu 20.04 LTS linux-aws 5.4.0-1102.110 —
Ubuntu 20.04 LTS linux-aws-5.15 5.15.0-1036.40~20.04.1 —
Ubuntu 20.04 LTS linux-azure 5.4.0-1108.114 —
Ubuntu 20.04 LTS linux-azure-5.15 5.15.0-1038.45~20.04.1 —
Ubuntu 20.04 LTS linux-bluefield 5.4.0-1064.70 —
Ubuntu 20.04 LTS linux-gcp 5.4.0-1105.114 —
Ubuntu 20.04 LTS linux-gcp-5.15 5.15.0-1034.42~20.04.1 —
Ubuntu 20.04 LTS linux-gke +26 No fix yet —
Ubuntu 20.04 LTS linux-gkeop 5.4.0-1069.73 —
Ubuntu 20.04 LTS linux-gkeop-5.15 5.15.0-1020.25~20.04.1 —
Ubuntu 20.04 LTS linux-hwe-5.15 +1 5.15.0-72.79~20.04.1 —
Ubuntu 20.04 LTS linux-ibm 5.4.0-1049.54 —
Ubuntu 20.04 LTS linux-intel-iotg-5.15 5.15.0-1030.35~20.04.1 —
Ubuntu 20.04 LTS linux-iot 5.4.0-1017.18 —
Ubuntu 20.04 LTS linux-kvm 5.4.0-1091.97 —
Ubuntu 20.04 LTS linux-nvidia-tegra-5.15 5.15.0-1014.14~20.04.1 —
Ubuntu 20.04 LTS linux-oracle 5.4.0-1101.110 —
Ubuntu 20.04 LTS linux-oracle-5.15 5.15.0-1035.41~20.04.1 —
Ubuntu 20.04 LTS linux-raspi 5.4.0-1085.96 —
Ubuntu 20.04 LTS linux-riscv-5.15 5.15.0-1033.37~20.04.1 —
Ubuntu 20.04 LTS linux-xilinx-zynqmp 5.4.0-1024.28 —
Ubuntu 18.04 LTS linux-aws-5.4 5.4.0-1103.111~18.04.1 —
Ubuntu 18.04 LTS linux-azure-5.4 5.4.0-1108.114~18.04.1 —
Ubuntu 18.04 LTS linux-gcp +14 No fix yet —
Ubuntu 18.04 LTS linux-gcp-5.4 5.4.0-1105.114~18.04.1 —
Ubuntu 18.04 LTS linux-hwe-5.4 5.4.0-149.166~18.04.1 —
Ubuntu 18.04 LTS linux-ibm-5.4 5.4.0-1049.54~18.04.1 —
Ubuntu 18.04 LTS linux-oracle-5.4 5.4.0-1101.110~18.04.1 —
Ubuntu 18.04 LTS linux-raspi-5.4 5.4.0-1085.96~18.04.1 —
Show 4 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Ubuntu 16.04 LTS linux-hwe-edge No fix yet —
Ubuntu Pro Realtime 22.04 LTS linux-intel-iot-realtime 5.15.0-1028.33 —
Ubuntu Pro Realtime 22.04 LTS linux-realtime 5.15.0-1038.41 —
Ubuntu Pro FIPS 20.04 LTS linux-fips +3 No fix yet —
Ubuntu Pro FIPS-updates 20.04 LTS linux-aws-fips 5.4.0-1102.110+fips1 —
Ubuntu Pro FIPS-updates 20.04 LTS linux-azure-fips 5.4.0-1108.114+fips1 —
Ubuntu Pro FIPS-updates 20.04 LTS linux-fips 5.4.0-1077.86 —
Ubuntu Pro FIPS-updates 20.04 LTS linux-gcp-fips 5.4.0-1105.114+fips1 —
ReleasePackageFixed inAdvisory
RHEL 9 bpftool 7.2.0-362.8.1.el9_3 RHSA-2023:6583
RHEL 9 rv +64 5.14.0-362.8.1.el9_3 RHSA-2023:6583
RHEL 8 kernel-rt +12 4.18.0-553.16.1.rt7.357.el8_10 RHSA-2024:5102
RHEL 8 perf +26 4.18.0-553.16.1.el8_10 RHSA-2024:5101
Show 1 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
RHEL 9.2 EUS bpftool 7.0.0-284.75.1.el9_2 RHSA-2024:4823
RHEL 9.2 EUS kernel-rt +14 5.14.0-284.75.1.rt14.360.el9_2 RHSA-2024:4831
RHEL 9.2 EUS perf +48 5.14.0-284.75.1.el9_2 RHSA-2024:4823

AlmaLinux

Errata ↗
ReleasePackageFixed inAdvisory
AlmaLinux 8 kernel-rt +11 4.18.0-553.16.1.rt7.357.el8_10 ALSA-2024:5102
AlmaLinux 8 perf +24 4.18.0-553.16.1.el8_10 ALSA-2024:5101

Rocky Linux

Errata ↗
ReleasePackageFixed inAdvisory
Rocky Linux 8 kernel 4.18.0-553.16.1.el8_10 RXSA-2024:5101, RLSA-2024:5101
Rocky Linux 8 kernel-rt 4.18.0-553.16.1.rt7.357.el8_10 RLSA-2024:5102
ReleasePackageFixed inAdvisory
SLES 15 SP5 kernel-64kb +6 5.14.21-150500.55.68.1 SUSE-SU-2024:2190-1
SLES 15 SP5 kernel-azure +2 5.14.21-150500.33.57.1 SUSE-SU-2024:2019-1
SLES 15 SP5 kernel-default-base 5.14.21-150500.55.68.1.150500.6.31.1 SUSE-SU-2024:2190-1
SLES 15 SP4 kernel-64kb +4 5.14.21-150400.24.122.2 SUSE-SU-2024:2189-1
SLES 15 SP4 kernel-default-base 5.14.21-150400.24.122.2.150400.24.58.2 SUSE-SU-2024:2189-1
SLES 15 SP4 kernel-syms +1 5.14.21-150400.24.122.1 SUSE-SU-2024:2189-1
SLES 15 SP3 kernel-64kb +7 5.3.18-150300.59.167.1 SUSE-SU-2024:2362-1
SLES 15 SP3 kernel-default-base 5.3.18-150300.59.167.1.150300.18.98.1 SUSE-SU-2024:2362-1
SLES 15 SP2 kernel-default-base 5.3.18-150200.24.197.1.150200.9.101.1 SUSE-SU-2024:2365-1
SLES 15 SP2 kernel-docs +5 5.3.18-150200.24.197.1 SUSE-SU-2024:2365-1
Show 19 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
SLES for SAP 15 SP4 kernel-default-base 5.14.21-150400.24.122.2.150400.24.58.2 SUSE-SU-2024:2189-1
SLES for SAP 15 SP4 kernel-docs +2 5.14.21-150400.24.122.2 SUSE-SU-2024:2189-1
SLES for SAP 15 SP4 kernel-syms +1 5.14.21-150400.24.122.1 SUSE-SU-2024:2189-1
SLES for SAP 15 SP3 kernel-default-base 5.3.18-150300.59.167.1.150300.18.98.1 SUSE-SU-2024:2362-1
SLES for SAP 15 SP3 kernel-docs +5 5.3.18-150300.59.167.1 SUSE-SU-2024:2362-1
SLES for SAP 15 SP2 kernel-default-base 5.3.18-150200.24.197.1.150200.9.101.1 SUSE-SU-2024:2365-1
SLES for SAP 15 SP2 kernel-docs +5 5.3.18-150200.24.197.1 SUSE-SU-2024:2365-1
SLE Micro 5.5 kernel-default 5.14.21-150500.55.68.1 SUSE-SU-2024:2190-1
SLE Micro 5.5 kernel-default-base 5.14.21-150500.55.68.1.150500.6.31.1 SUSE-SU-2024:2190-1
SLE Micro 5.5 kernel-rt +1 5.14.21-150500.13.58.1 SUSE-SU-2024:2008-1
SLE Micro 5.4 kernel-default 5.14.21-150400.24.122.2 SUSE-SU-2024:2189-1
SLE Micro 5.4 kernel-default-base 5.14.21-150400.24.122.2.150400.24.58.2 SUSE-SU-2024:2189-1
SLE Micro 5.4 kernel-rt +1 5.14.21-150400.15.82.1 SUSE-SU-2024:2011-1
SLE Micro 5.3 kernel-default 5.14.21-150400.24.122.2 SUSE-SU-2024:2189-1
SLE Micro 5.3 kernel-default-base 5.14.21-150400.24.122.2.150400.24.58.2 SUSE-SU-2024:2189-1
SLE Micro 5.3 kernel-rt +1 5.14.21-150400.15.82.1 SUSE-SU-2024:2011-1
SLE Micro 5.2 kernel-default 5.3.18-150300.59.167.1 SUSE-SU-2024:2362-1
SLE Micro 5.2 kernel-default-base 5.3.18-150300.59.167.1.150300.18.98.1 SUSE-SU-2024:2362-1
SLE Micro 5.2 kernel-rt +1 5.3.18-150300.175.1 SUSE-SU-2024:2384-1
SLE Micro 5.1 kernel-default 5.3.18-150300.59.167.1 SUSE-SU-2024:2362-1
SLE Micro 5.1 kernel-default-base 5.3.18-150300.59.167.1.150300.18.98.1 SUSE-SU-2024:2362-1
SLE Micro 5.1 kernel-rt +1 5.3.18-150300.175.1 SUSE-SU-2024:2384-1
SLE Live Patching 15 SP5 kernel-default 5.14.21-150500.55.68.1 SUSE-SU-2024:2190-1
SLE Live Patching 15 SP5 kernel-livepatch-SLE15-SP5_Update_15 +1 1-150500.11.3.1 SUSE-SU-2024:2190-1, SUSE-SU-2024:2008-1
SLE Live Patching 15 SP4 kernel-default 5.14.21-150400.24.122.2 SUSE-SU-2024:2189-1
SLE Live Patching 15 SP4 kernel-livepatch-SLE15-SP4_Update_27 1-150400.9.3.2 SUSE-SU-2024:2189-1
SLE Live Patching 15 SP3 kernel-default 5.3.18-150300.59.167.1 SUSE-SU-2024:2362-1
SLE Live Patching 15 SP3 kernel-livepatch-SLE15-SP3_Update_46 1-150300.7.3.1 SUSE-SU-2024:2362-1
SLE Live Patching 15 SP2 kernel-default 5.3.18-150200.24.197.1 SUSE-SU-2024:2365-1
SLE Live Patching 15 SP2 kernel-livepatch-SLE15-SP2_Update_50 1-150200.5.3.1 SUSE-SU-2024:2365-1
SLE HPC 15 SP4 kernel-64kb +3 5.14.21-150400.24.122.2 SUSE-SU-2024:2189-1
SLE HPC 15 SP4 kernel-default-base 5.14.21-150400.24.122.2.150400.24.58.2 SUSE-SU-2024:2189-1
SLE HPC 15 SP4 kernel-syms +1 5.14.21-150400.24.122.1 SUSE-SU-2024:2189-1
SLE HPC 15 SP3 kernel-64kb +6 5.3.18-150300.59.167.1 SUSE-SU-2024:2362-1
SLE HPC 15 SP3 kernel-default-base 5.3.18-150300.59.167.1.150300.18.98.1 SUSE-SU-2024:2362-1
SLE HPC 15 SP2 kernel-default-base 5.3.18-150200.24.197.1.150200.9.101.1 SUSE-SU-2024:2365-1
SLE HPC 15 SP2 kernel-docs +5 5.3.18-150200.24.197.1 SUSE-SU-2024:2365-1
SUSE Real Time Module 15 SP5 kernel-rt +3 5.14.21-150500.13.58.1 SUSE-SU-2024:2008-1
SUSE Manager Server 4.3 kernel-default +1 5.14.21-150400.24.122.2 SUSE-SU-2024:2189-1
SUSE Manager Server 4.3 kernel-default-base 5.14.21-150400.24.122.2.150400.24.58.2 SUSE-SU-2024:2189-1
SUSE Manager Server 4.3 kernel-syms +1 5.14.21-150400.24.122.1 SUSE-SU-2024:2189-1
SUSE Manager Proxy 4.3 kernel-default 5.14.21-150400.24.122.2 SUSE-SU-2024:2189-1
SUSE Manager Proxy 4.3 kernel-default-base 5.14.21-150400.24.122.2.150400.24.58.2 SUSE-SU-2024:2189-1
SUSE Manager Proxy 4.3 kernel-syms +1 5.14.21-150400.24.122.1 SUSE-SU-2024:2189-1
SUSE Enterprise Storage 7.1 kernel-64kb +6 5.3.18-150300.59.167.1 SUSE-SU-2024:2362-1
SUSE Enterprise Storage 7.1 kernel-default-base 5.3.18-150300.59.167.1.150300.18.98.1 SUSE-SU-2024:2362-1
ReleasePackageFixed inAdvisory
openSUSE Leap 15.5 dtb-aarch64 +10 5.14.21-150500.55.68.1 SUSE-SU-2024:2190-1
openSUSE Leap 15.5 kernel-azure +2 5.14.21-150500.33.57.1 SUSE-SU-2024:2019-1
openSUSE Leap 15.5 kernel-default-base 5.14.21-150500.55.68.1.150500.6.31.1 SUSE-SU-2024:2190-1
openSUSE Leap 15.5 kernel-rt +3 5.14.21-150500.13.58.1 SUSE-SU-2024:2008-1
Show 2 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
openSUSE Leap Micro 5.4 kernel-default 5.14.21-150400.24.122.2 SUSE-SU-2024:2189-1
openSUSE Leap Micro 5.4 kernel-default-base 5.14.21-150400.24.122.2.150400.24.58.2 SUSE-SU-2024:2189-1
openSUSE Leap Micro 5.4 kernel-rt 5.14.21-150400.15.82.1 SUSE-SU-2024:2011-1
openSUSE Leap Micro 5.3 kernel-default 5.14.21-150400.24.122.2 SUSE-SU-2024:2189-1
openSUSE Leap Micro 5.3 kernel-default-base 5.14.21-150400.24.122.2.150400.24.58.2 SUSE-SU-2024:2189-1
openSUSE Leap Micro 5.3 kernel-rt 5.14.21-150400.15.82.1 SUSE-SU-2024:2011-1

Amazon Linux

ReleasePackageFixed inAdvisory
Amazon Linux 2023 kernel-livepatch-6.1.15-28.43 1.0-0.amzn2023 ALAS2023-2023-127
Amazon Linux 2023 perf +12 6.1.15-28.43.amzn2023 ALAS2023-2023-127

Oracle Linux

ReleasePackageFixed inAdvisory
Oracle Linux 8 perf +19 4.18.0-553.16.1.el8_10 ELSA-2024-5101

Advisories 22

References