Vulnerability · Published Jul 12, 2024 · Assigned by Linux

CVE-2024-39500sock_map: avoid race between sock_map_close and sk_psock_put

High 7.8

In plain English

A high-severity security flaw in Linux from Linux. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 0.2% (higher than 13% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS 3.1)7.8High
Exploit odds (30 days)0.2%top 87.2% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack toolingNoneno public tooling known

Official description

In the Linux kernel, the following vulnerability has been resolved: sock_map: avoid race between sock_map_close and sk_psock_put sk_psock_get will return NULL if the refcount of psock has gone to 0, which will happen when the last call of sk_psock_put is done. However, sk_psock_drop may not have finished yet, so the close callback will still point to sock_map_close despite psock being NULL. This can be reproduced with a thread deleting an element from the sock map, while the second one creates a socket, adds it to the map and closes it. That will trigger the WARN_ON_ONCE: ------------[ cut here ]------------ WARNING: CPU: 1 PID: 7220 at net/core/sock_map.c:1701 sock_map_close+0x2a2/0x2d0 net/core/sock_map.c:1701 Modules linked in: CPU: 1 PID: 7220 Comm: syz-executor380 Not tainted 6.9.0-syzkaller-07726-g3c999d1ae3c7 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024 RIP: 0010:sock_map_close+0x2a2/0x2d0 net/core/sock_map.c:1701 Code: df e8 92 29 88 f8 48 8b 1b 48 89 d8 48 c1 e8 03 42 80 3c 20 00 74 08 48 89 df e8 79 29 88 f8 4c 8b 23 eb 89 e8 4f 15 23 f8 90 <0f> 0b 90 48 83 c4 08 5b 41 5c 41 5d 41 5e 41 5f 5d e9 13 26 3d 02 RSP: 0018:ffffc9000441fda8 EFLAGS: 00010293 RAX: ffffffff89731ae1 RBX: ffffffff94b87540 RCX: ffff888029470000 RDX: 0000000000000000 RSI: ffffffff8bcab5c0 RDI: ffffffff8c1faba0 RBP: 0000000000000000 R08: ffffffff92f9b61f R09: 1ffffffff25f36c3 R10: dffffc0000000000 R11: fffffbfff25f36c4 R12: ffffffff89731840 R13: ffff88804b587000 R14: ffff88804b587000 R15: ffffffff89731870 FS: 000055555e080380(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 00000000207d4000 CR4: 0000000000350ef0 Call Trace: <TASK> unix_release+0x87/0xc0 net/unix/af_unix.c:1048 __sock_release net/socket.c:659 [inline] sock_close+0xbe/0x240 net/socket.c:1421 __fput+0x42b/0x8a0 fs/file_table.c:422 __do_sys_close fs/open.c:1556 [inline] __se_sys_close fs/open.c:1541 [inline] __x64_sys_close+0x7f/0x110 fs/open.c:1541 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fb37d618070 Code: 00 00 48 c7 c2 b8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff eb d4 e8 10 2c 00 00 80 3d 31 f0 07 00 00 74 17 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 48 c3 0f 1f 80 00 00 00 00 48 83 ec 18 89 7c RSP: 002b:00007ffcd4a525d8 EFLAGS: 00000202 ORIG_RAX: 0000000000000003 RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00007fb37d618070 RDX: 0000000000000010 RSI: 00000000200001c0 RDI: 0000000000000004 RBP: 0000000000000000 R08: 0000000100000000 R09: 0000000100000000 R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 </TASK> Use sk_psock, which will only check that the pointer is not been set to NULL yet, which should only happen after the callbacks are restored. If, then, a reference can still be gotten, we may call sk_psock_stop and cancel psock->work. As suggested by Paolo Abeni, reorder the condition so the control flow is less convoluted. After that change, the reproducer does not trigger the WARN_ON_ONCE anymore.

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
Debian:12linux6.1.99-1DEBIAN-CVE-2024-39500
Debian:12linux6.1.99-1DSA-5731-1
Debian:13linux6.9.7-1DEBIAN-CVE-2024-39500
Debian:14linux6.9.7-1DEBIAN-CVE-2024-39500
Ubuntu:22.04:LTSlinux5.15.0-121.131UBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux6.8.0-44.44UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-allwinner-5.19no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-aws5.15.0-1069.75UBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux-aws6.8.0-1015.16UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-aws-5.19no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-aws-6.2no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-aws-6.5no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-aws-6.86.8.0-1015.16~22.04.1UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-azure5.15.0-1072.81UBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux-azure6.8.0-1014.16UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-azure-5.19no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-azure-6.2no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-azure-6.5no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-azure-6.86.8.0-1014.16~22.04.1UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-azure-fde5.15.0-1072.81.1UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-azure-fde-5.19no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-azure-fde-6.2no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-gcp5.15.0-1068.76UBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux-gcp6.8.0-1014.16UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-gcp-5.19no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-gcp-6.2no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-gcp-6.5no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-gcp-6.86.8.0-1014.16~22.04.1UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-gke5.15.0-1066.72UBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux-gke6.8.0-1010.13UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-gkeop5.15.0-1052.59UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-hwe-5.19no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-hwe-6.2no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-hwe-6.5no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-hwe-6.86.8.0-45.45~22.04.1UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-ibm5.15.0-1062.65UBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux-ibm6.8.0-1012.12UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-ibm-6.86.8.0-1012.12~22.04.1UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-intel-iotg5.15.0-1064.70UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-kvm5.15.0-1066.71UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-lowlatency5.15.0-121.131UBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux-lowlatency6.8.0-44.44.1UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-lowlatency-hwe-5.19no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.2no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.5no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.86.8.0-44.44.1~22.04.1UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-nvidia5.15.0-1064.65UBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux-nvidia6.8.0-1013.14UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-nvidia-6.2no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-nvidia-6.5no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-nvidia-6.86.8.0-1013.14~22.04.1UBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux-nvidia-lowlatency6.8.0-1013.14.1UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-nvidia-tegra5.15.0-1028.28UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-nvidia-tegra-igx5.15.0-1016.16UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-oem-5.17no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-oem-6.0no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-oem-6.1no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-oem-6.5no fix listedUBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux-oem-6.86.8.0-1012.12UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-oracle5.15.0-1067.73UBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux-oracle6.8.0-1012.12UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-oracle-6.5no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-oracle-6.86.8.0-1012.12~22.04.1UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-raspi5.15.0-1062.65UBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux-raspi6.8.0-1011.12UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-realtimeno fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-riscvno fix listedUBUNTU-CVE-2024-39500
Ubuntu:24.04:LTSlinux-riscv6.8.0-44.44.1UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-riscv-5.19no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-riscv-6.5no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-riscv-6.86.8.0-44.44.1~22.04.1UBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-starfive-5.19no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-starfive-6.2no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-starfive-6.5no fix listedUBUNTU-CVE-2024-39500
Ubuntu:22.04:LTSlinux-xilinx-zynqmp5.15.0-1035.39UBUNTU-CVE-2024-39500

Affected products (as reported)

VendorProductVersions
Linux Linux aadb2bb83ff789de63b48b4edeab7329423a50d3 – before 4959ffc65a0e94f8acaac20deac49f89e6ded52daadb2bb83ff789de63b48b4edeab7329423a50d3 – before 5eabdf17fed2ad41b836bb4055ec36d95e512c50aadb2bb83ff789de63b48b4edeab7329423a50d3 – before e946428439a0d2079959f5603256ac51b6047017aadb2bb83ff789de63b48b4edeab7329423a50d3 – before 3627605de498639a3c586c8684d12c89cba11073aadb2bb83ff789de63b48b4edeab7329423a50d3 – before 4b4647add7d3c8530493f7247d11e257ee425bf0c4896f5fd83664a50ac4fef4131a265d15734e5a5.10.248 – before 5.11
Linux Linux 5.13

References