Vulnerability · Published Dec 27, 2024 · Assigned by Linux
CVE-2024-56664bpf, sockmap: Fix race between element replace and close()
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 8% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.
Official description
In the Linux kernel, the following vulnerability has been resolved: bpf, sockmap: Fix race between element replace and close() Element replace (with a socket different from the one stored) may race with socket's close() link popping & unlinking. __sock_map_delete() unconditionally unrefs the (wrong) element: // set map[0] = s0 map_update_elem(map, 0, s0) // drop fd of s0 close(s0) sock_map_close() lock_sock(sk) (s0!) sock_map_remove_links(sk) link = sk_psock_link_pop() sock_map_unlink(sk, link) sock_map_delete_from_link // replace map[0] with s1 map_update_elem(map, 0, s1) sock_map_update_elem (s1!) lock_sock(sk) sock_map_update_common psock = sk_psock(sk) spin_lock(&stab->lock) osk = stab->sks[idx] sock_map_add_link(..., &stab->sks[idx]) sock_map_unref(osk, &stab->sks[idx]) psock = sk_psock(osk) sk_psock_put(sk, psock) if (refcount_dec_and_test(&psock)) sk_psock_drop(sk, psock) spin_unlock(&stab->lock) unlock_sock(sk) __sock_map_delete spin_lock(&stab->lock) sk = *psk // s1 replaced s0; sk == s1 if (!sk_test || sk_test == sk) // sk_test (s0) != sk (s1); no branch sk = xchg(psk, NULL) if (sk) sock_map_unref(sk, psk) // unref s1; sks[idx] will dangle psock = sk_psock(sk) sk_psock_put(sk, psock) if (refcount_dec_and_test()) sk_psock_drop(sk, psock) spin_unlock(&stab->lock) release_sock(sk) Then close(map) enqueues bpf_map_free_deferred, which finally calls sock_map_free(). This results in some refcount_t warnings along with a KASAN splat [1]. Fix __sock_map_delete(), do not allow sock_map_unref() on elements that may have been replaced. [1]: BUG: KASAN: slab-use-after-free in sock_map_free+0x10e/0x330 Write of size 4 at addr ffff88811f5b9100 by task kworker/u64:12/1063 CPU: 14 UID: 0 PID: 1063 Comm: kworker/u64:12 Not tainted 6.12.0+ #125 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Arch Linux 1.16.3-1-1 04/01/2014 Workqueue: events_unbound bpf_map_free_deferred Call Trace: <TASK> dump_stack_lvl+0x68/0x90 print_report+0x174/0x4f6 kasan_report+0xb9/0x190 kasan_check_range+0x10f/0x1e0 sock_map_free+0x10e/0x330 bpf_map_free_deferred+0x173/0x320 process_one_work+0x846/0x1420 worker_thread+0x5b3/0xf80 kthread+0x29e/0x360 ret_from_fork+0x2d/0x70 ret_from_fork_asm+0x1a/0x30 </TASK> Allocated by task 1202: kasan_save_stack+0x1e/0x40 kasan_save_track+0x10/0x30 __kasan_slab_alloc+0x85/0x90 kmem_cache_alloc_noprof+0x131/0x450 sk_prot_alloc+0x5b/0x220 sk_alloc+0x2c/0x870 unix_create1+0x88/0x8a0 unix_create+0xc5/0x180 __sock_create+0x241/0x650 __sys_socketpair+0x1ce/0x420 __x64_sys_socketpair+0x92/0x100 do_syscall_64+0x93/0x180 entry_SYSCALL_64_after_hwframe+0x76/0x7e Freed by task 46: kasan_save_stack+0x1e/0x40 kasan_save_track+0x10/0x30 kasan_save_free_info+0x37/0x60 __kasan_slab_free+0x4b/0x70 kmem_cache_free+0x1a1/0x590 __sk_destruct+0x388/0x5a0 sk_psock_destroy+0x73e/0xa50 process_one_work+0x846/0x1420 worker_thread+0x5b3/0xf80 kthread+0x29e/0x360 ret_from_fork+0x2d/0x70 ret_from_fork_asm+0x1a/0x30 The bu ---truncated---
Affected packages & fixed versions
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian:12 | linux | 6.1.128-1 | DSA-5860-1 |
| Debian:12 | linux | 6.1.128-1 | DEBIAN-CVE-2024-56664 |
| Debian:13 | linux | 6.12.6-1 | DEBIAN-CVE-2024-56664 |
| Debian:14 | linux | 6.12.6-1 | DEBIAN-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux | 5.15.0-142.152 | USN-7591-1 |
| Ubuntu:22.04:LTS | linux | 5.15.0-142.152 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux | 6.8.0-60.63 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux | 6.8.0-60.63 | USN-7513-1 |
| Ubuntu:22.04:LTS | linux-allwinner-5.19 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-aws | 5.15.0-1086.93 | USN-7591-4 |
| Ubuntu:22.04:LTS | linux-aws | 5.15.0-1086.93 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-aws | 6.8.0-1029.31 | USN-7513-1 |
| Ubuntu:24.04:LTS | linux-aws | 6.8.0-1029.31 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-aws-5.19 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-aws-6.2 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-aws-6.5 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-aws-6.8 | 6.8.0-1029.31~22.04.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-aws-6.8 | 6.8.0-1029.31~22.04.1 | USN-7513-1 |
| Ubuntu:22.04:LTS | linux-azure | 5.15.0-1091.100 | USN-7597-1 |
| Ubuntu:22.04:LTS | linux-azure | 5.15.0-1091.100 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-azure | 6.8.0-1029.34 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-azure | 6.8.0-1029.34 | USN-7513-3 |
| Ubuntu:22.04:LTS | linux-azure-5.19 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-azure-6.11 | 6.11.0-1012.12~24.04.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-azure-6.2 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-azure-6.5 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-azure-6.8 | 6.8.0-1029.34~22.04.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-azure-6.8 | 6.8.0-1029.34~22.04.1 | USN-7513-3 |
| Ubuntu:22.04:LTS | linux-azure-fde | 5.15.0-1091.100.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-azure-fde-5.19 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-azure-fde-6.2 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-azure-nvidia | 6.8.0-1016.17 | USN-7522-1 |
| Ubuntu:24.04:LTS | linux-azure-nvidia | 6.8.0-1016.17 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-gcp | 5.15.0-1085.94 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-gcp | 5.15.0-1085.94 | USN-7591-1 |
| Ubuntu:24.04:LTS | linux-gcp | 6.8.0-1030.32 | USN-7515-2 |
| Ubuntu:24.04:LTS | linux-gcp | 6.8.0-1030.32 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-gcp-5.19 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-gcp-6.11 | 6.11.0-1011.11~24.04.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-gcp-6.2 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-gcp-6.5 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-gcp-6.8 | 6.8.0-1030.32~22.04.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-gcp-6.8 | 6.8.0-1030.32~22.04.1 | USN-7515-2 |
| Ubuntu:22.04:LTS | linux-gke | 5.15.0-1083.89 | USN-7591-1 |
| Ubuntu:22.04:LTS | linux-gke | 5.15.0-1083.89 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-gke | 6.8.0-1025.29 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-gke | 6.8.0-1025.29 | USN-7515-1 |
| Ubuntu:22.04:LTS | linux-gkeop | 5.15.0-1068.76 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-gkeop | 5.15.0-1068.76 | USN-7591-1 |
| Ubuntu:24.04:LTS | linux-gkeop | 6.8.0-1012.14 | USN-7515-2 |
| Ubuntu:24.04:LTS | linux-gkeop | 6.8.0-1012.14 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-hwe-5.19 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-hwe-6.11 | 6.11.0-21.21~24.04.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-hwe-6.2 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-hwe-6.5 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-hwe-6.8 | 6.8.0-60.63~22.04.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-hwe-6.8 | 6.8.0-60.63~22.04.1 | USN-7513-4 |
| Ubuntu:22.04:LTS | linux-ibm | 5.15.0-1078.81 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-ibm | 5.15.0-1078.81 | USN-7591-1 |
| Ubuntu:24.04:LTS | linux-ibm | 6.8.0-1026.26 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-ibm | 6.8.0-1026.26 | USN-7513-1 |
| Ubuntu:22.04:LTS | linux-ibm-6.8 | 6.8.0-1026.26~22.04.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-intel-iot-realtime | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-intel-iotg | 5.15.0-1081.87 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-intel-iotg | 5.15.0-1081.87 | USN-7591-5 |
| Ubuntu:22.04:LTS | linux-kvm | 5.15.0-1082.87 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-kvm | 5.15.0-1082.87 | USN-7591-1 |
| Ubuntu:22.04:LTS | linux-lowlatency | 5.15.0-142.152 | USN-7591-1 |
| Ubuntu:22.04:LTS | linux-lowlatency | 5.15.0-142.152 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-lowlatency | 6.8.0-60.63.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-lowlatency | 6.8.0-60.63.1 | USN-7513-1 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-5.19 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.2 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.5 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.8 | 6.8.0-60.63.1~22.04.1 | USN-7513-1 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.8 | 6.8.0-60.63.1~22.04.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-nvidia | 5.15.0-1080.81 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-nvidia | 5.15.0-1080.81 | USN-7591-1 |
| Ubuntu:24.04:LTS | linux-nvidia | 6.8.0-1028.31 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-nvidia | 6.8.0-1028.31 | USN-7514-1 |
| Ubuntu:24.04:LTS | linux-nvidia-6.11 | 6.11.0-1007.7 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-nvidia-6.2 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-nvidia-6.5 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-nvidia-6.8 | 6.8.0-1028.31~22.04.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-nvidia-6.8 | 6.8.0-1028.31~22.04.1 | USN-7514-1 |
| Ubuntu:24.04:LTS | linux-nvidia-lowlatency | 6.8.0-1028.31.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-nvidia-lowlatency | 6.8.0-1028.31.1 | USN-7514-1 |
| Ubuntu:22.04:LTS | linux-nvidia-tegra | 5.15.0-1039.39 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-nvidia-tegra | 5.15.0-1039.39 | USN-7591-1 |
| Ubuntu:24.04:LTS | linux-nvidia-tegra | 6.8.0-1008.8 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-nvidia-tegra-igx | 5.15.0-1028.28 | USN-7591-1 |
| Ubuntu:22.04:LTS | linux-nvidia-tegra-igx | 5.15.0-1028.28 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-oem-5.17 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-oem-6.0 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-oem-6.1 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-oem-6.11 | 6.11.0-1017.17 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-oem-6.5 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-oem-6.8 | 6.8.0-1028.28 | USN-7513-3 |
| Ubuntu:24.04:LTS | linux-oem-6.8 | 6.8.0-1028.28 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-oracle | 5.15.0-1083.89 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-oracle | 5.15.0-1083.89 | USN-7591-1 |
| Ubuntu:24.04:LTS | linux-oracle | 6.8.0-1026.27 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-oracle | 6.8.0-1026.27 | USN-7513-1 |
| Ubuntu:22.04:LTS | linux-oracle-6.5 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-oracle-6.8 | 6.8.0-1026.27~22.04.1 | USN-7513-5 |
| Ubuntu:22.04:LTS | linux-oracle-6.8 | 6.8.0-1026.27~22.04.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-raspi | 5.15.0-1080.83 | USN-7591-6 |
| Ubuntu:22.04:LTS | linux-raspi | 5.15.0-1080.83 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-raspi | 6.8.0-1028.32 | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-raspi-realtime | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-realtime | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-realtime | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-riscv | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-riscv | 6.8.0-60.63.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-riscv-5.19 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-riscv-6.5 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-riscv-6.8 | 6.8.0-62.65~22.04.1 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-starfive-5.19 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-starfive-6.2 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-starfive-6.5 | no fix listed | UBUNTU-CVE-2024-56664 |
| Ubuntu:24.04:LTS | linux-xilinx | 6.8.0-1017.18 | UBUNTU-CVE-2024-56664 |
| Ubuntu:22.04:LTS | linux-xilinx-zynqmp | 5.15.0-1050.54 | USN-7602-1 |
| Ubuntu:22.04:LTS | linux-xilinx-zynqmp | 5.15.0-1050.54 | UBUNTU-CVE-2024-56664 |
Affected products (as reported)
| Vendor | Product | Versions |
|---|---|---|
| Linux | Linux | 604326b41a6fb9b4a78b6179335decee0365cd8c – before 6deb9e85dc9a2ba4414b91c1b5b00b8415910890604326b41a6fb9b4a78b6179335decee0365cd8c – before fdb2cd8957ac51f84c9e742ba866087944bb834b604326b41a6fb9b4a78b6179335decee0365cd8c – before b79a0d1e9a374d1b376933a354c4fcd01fce0365604326b41a6fb9b4a78b6179335decee0365cd8c – before b015f19fedd2e12283a8450dd0aefce49ec57015604326b41a6fb9b4a78b6179335decee0365cd8c – before bf2318e288f636a882eea39f7e1015623629f168604326b41a6fb9b4a78b6179335decee0365cd8c – before ed1fc5d76b81a4d681211333c026202cad4d5649 |
| Linux | Linux | 4.20 |
References
- https://git.kernel.org/stable/c/6deb9e85dc9a2ba4414b91c1b5b00b8415910890
- https://git.kernel.org/stable/c/fdb2cd8957ac51f84c9e742ba866087944bb834b
- https://git.kernel.org/stable/c/b79a0d1e9a374d1b376933a354c4fcd01fce0365
- https://git.kernel.org/stable/c/b015f19fedd2e12283a8450dd0aefce49ec57015
- https://git.kernel.org/stable/c/bf2318e288f636a882eea39f7e1015623629f168
- https://git.kernel.org/stable/c/ed1fc5d76b81a4d681211333c026202cad4d5649
- https://lists.debian.org/debian-lts-announce/2025/05/msg00030.html
- https://lists.debian.org/debian-lts-announce/2025/03/msg00001.html