CVE-2024-40954
net: do not leave a dangling sk pointer, when socket creation fails
Mitigation
- Upgrade Linux to 6cd4a78d962bebbaf8beb7d2ead3f34120e3f7b2 or later.
Who should check
- Anyone running Linux >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 78e4aa528a7b1204219d808310524344f627d069; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 893eeba94c40d513cd0fe6539330ebdaea208c0e; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 454c454ed645fed051216b79622f7cb69c1638f5; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 5dfe2408fd7dc4d2e7ac38a116ff0a37b1cfd3b9; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 6cd4a78d962bebbaf8beb7d2ead3f34120e3f7b2
- Anyone running Linux 5.12
Vulnerability facts
- Affected
- Linux >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 78e4aa528a7b1204219d808310524344f627d069; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 893eeba94c40d513cd0fe6539330ebdaea208c0e; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 454c454ed645fed051216b79622f7cb69c1638f5; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 5dfe2408fd7dc4d2e7ac38a116ff0a37b1cfd3b9; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 6cd4a78d962bebbaf8beb7d2ead3f34120e3f7b2; Linux 5.12
- Fixed in
- Linux 78e4aa528a7b1204219d808310524344f627d069, Linux 893eeba94c40d513cd0fe6539330ebdaea208c0e, Linux 454c454ed645fed051216b79622f7cb69c1638f5, Linux 5dfe2408fd7dc4d2e7ac38a116ff0a37b1cfd3b9, Linux 6cd4a78d962bebbaf8beb7d2ead3f34120e3f7b2
- Exploited in the wild
- Not in CISA KEV
- Public exploit / PoC
- None known
- Remote exploitation
- Not remotely exploitable (local or adjacent access needed)
- CVSS
- 7.8 (v3.1, CNA)CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:HOpen in CVSS calculator
Show all 8 CVSS metrics
- Attack vector: Local
- Attack complexity: Low
- Privileges required: Low
- User interaction: None
- Scope: Unchanged
- Confidentiality impact: High
- Integrity impact: High
- Availability impact: High
- EPSS
- 0.32% chance of exploitation in 30 days (percentile 17, 2026-11-26)
- CWE
- CWE-416
- Modified
Description
In the Linux kernel, the following vulnerability has been resolved: net: do not leave a dangling sk pointer, when socket creation fails It is possible to trigger a use-after-free by: * attaching an fentry probe to __sock_release() and the probe calling the bpf_get_socket_cookie() helper * running traceroute -I 1.1.1.1 on a freshly booted VM A KASAN enabled kernel will log something like below (decoded and stripped): ================================================================== BUG: KASAN: slab-use-after-free in __sock_gen_cookie (./arch/x86/include/asm/atomic64_64.h:15 ./include/linux/atomic/atomic-arch-fallback.h:2583 ./include/linux/atomic/atomic-instrumented.h:1611 net/core/sock_diag.c:29) Read of size 8 at addr ffff888007110dd8 by task traceroute/299 CPU: 2 PID: 299 Comm: traceroute Tainted: G E 6.10.0-rc2+ #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 Call Trace: <TASK> dump_stack_lvl (lib/dump_stack.c:117 (discriminator 1)) print_report (mm/kasan/report.c:378 mm/kasan/report.c:488) ? __sock_gen_cookie (./arch/x86/include/asm/atomic64_64.h:15 ./include/linux/atomic/atomic-arch-fallback.h:2583 ./include/linux/atomic/atomic-instrumented.h:1611 net/core/sock_diag.c:29) kasan_report (mm/kasan/report.c:603) ? __sock_gen_cookie (./arch/x86/include/asm/atomic64_64.h:15 ./include/linux/atomic/atomic-arch-fallback.h:2583 ./include/linux/atomic/atomic-instrumented.h:1611 net/core/sock_diag.c:29) kasan_check_range (mm/kasan/generic.c:183 mm/kasan/generic.c:189) __sock_gen_cookie (./arch/x86/include/asm/atomic64_64.h:15 ./include/linux/atomic/atomic-arch-fallback.h:2583 ./include/linux/atomic/atomic-instrumented.h:1611 net/core/sock_diag.c:29) bpf_get_socket_ptr_cookie (./arch/x86/include/asm/preempt.h:94 ./include/linux/sock_diag.h:42 net/core/filter.c:5094 net/core/filter.c:5092) bpf_prog_875642cf11f1d139___sock_release+0x6e/0x8e bpf_trampoline_6442506592+0x47/0xaf __sock_release (net/socket.c:652) __sock_create (net/socket.c:1601) ... Allocated by task 299 on cpu 2 at 78.328492s: kasan_save_stack (mm/kasan/common.c:48) kasan_save_track (mm/kasan/common.c:68) __kasan_slab_alloc (mm/kasan/common.c:312 mm/kasan/common.c:338) kmem_cache_alloc_noprof (mm/slub.c:3941 mm/slub.c:4000 mm/slub.c:4007) sk_prot_alloc (net/core/sock.c:2075) sk_alloc (net/core/sock.c:2134) inet_create (net/ipv4/af_inet.c:327 net/ipv4/af_inet.c:252) __sock_create (net/socket.c:1572) __sys_socket (net/socket.c:1660 net/socket.c:1644 net/socket.c:1706) __x64_sys_socket (net/socket.c:1718) do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) Freed by task 299 on cpu 2 at 78.328502s: kasan_save_stack (mm/kasan/common.c:48) kasan_save_track (mm/kasan/common.c:68) kasan_save_free_info (mm/kasan/generic.c:582) poison_slab_object (mm/kasan/common.c:242) __kasan_slab_free (mm/kasan/common.c:256) kmem_cache_free (mm/slub.c:4437 mm/slub.c:4511) __sk_destruct (net/core/sock.c:2117 net/core/sock.c:2208) inet_create (net/ipv4/af_inet.c:397 net/ipv4/af_inet.c:252) __sock_create (net/socket.c:1572) __sys_socket (net/socket.c:1660 net/socket.c:1644 net/socket.c:1706) __x64_sys_socket (net/socket.c:1718) do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) Fix this by clearing the struct socket reference in sk_common_release() to cover all protocol families create functions, which may already attached the reference to the sk object with sock_init_data().
Affected and fixed versions
| Package / product | Affected | Fixed | Source |
|---|---|---|---|
| Linux | >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 78e4aa528a7b1204219d808310524344f627d069; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 893eeba94c40d513cd0fe6539330ebdaea208c0e; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 454c454ed645fed051216b79622f7cb69c1638f5; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 5dfe2408fd7dc4d2e7ac38a116ff0a37b1cfd3b9; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 6cd4a78d962bebbaf8beb7d2ead3f34120e3f7b2 | — | cvelist |
| Linux | 5.12 | — | cvelist |
Check your systems with an agent
Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.
Check whether anything I run is affected by CVE-2024-40954. Work read-only: do not install, upgrade, delete or change anything. Details: https://flawdb.com/CVE-2024-40954.md Affected: Linux >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 78e4aa528a7b1204219d808310524344f627d069; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 893eeba94c40d513cd0fe6539330ebdaea208c0e; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 454c454ed645fed051216b79622f7cb69c1638f5; >= c5dbb89fc2ac013afe67b9e… Fixed in: Linux 78e4aa528a7b1204219d808310524344f627d069, Linux 893eeba94c40d513cd0fe6539330ebdaea208c0e, Linux 454c454ed645fed051216b79622f7cb69c1638f5, Linux 5dfe2408fd7dc4d2e7ac38a116ff0a37b1cfd3b9, Linux 6cd4a78d962bebbaf8beb7d2ead3f34120e3f7b2 Steps: 1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services. 2. For each match, note the installed version and whether it is inside the affected range. 3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
References
Patches
- https://git.kernel.org/stable/c/78e4aa528a7b1204219d808310524344f627d069
- https://git.kernel.org/stable/c/893eeba94c40d513cd0fe6539330ebdaea208c0e
- https://git.kernel.org/stable/c/454c454ed645fed051216b79622f7cb69c1638f5
- https://git.kernel.org/stable/c/5dfe2408fd7dc4d2e7ac38a116ff0a37b1cfd3b9
- https://git.kernel.org/stable/c/6cd4a78d962bebbaf8beb7d2ead3f34120e3f7b2
FAQ
Is CVE-2024-40954 being exploited?
There is no confirmed exploitation: CVE-2024-40954 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.32% chance of exploitation in the next 30 days (as of 2026-11-26).
How serious is CVE-2024-40954?
High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).
Which versions are affected by CVE-2024-40954?
Linux >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 78e4aa528a7b1204219d808310524344f627d069; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 893eeba94c40d513cd0fe6539330ebdaea208c0e; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 454c454ed645fed051216b79622f7cb69c1638f5; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 5dfe2408fd7dc4d2e7ac38a116ff0a37b1cfd3b9; >= c5dbb89fc2ac013afe67b9e4fcb3743c02b567cd, < 6cd4a78d962bebbaf8beb7d2ead3f34120e3f7b2; Linux 5.12.
Is there a fix for CVE-2024-40954?
Yes. Fixed in Linux 78e4aa528a7b1204219d808310524344f627d069, Linux 893eeba94c40d513cd0fe6539330ebdaea208c0e, Linux 454c454ed645fed051216b79622f7cb69c1638f5, Linux 5dfe2408fd7dc4d2e7ac38a116ff0a37b1cfd3b9, Linux 6cd4a78d962bebbaf8beb7d2ead3f34120e3f7b2. Upgrade Linux to 6cd4a78d962bebbaf8beb7d2ead3f34120e3f7b2 or later.
How do I check if I'm affected by CVE-2024-40954?
Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.