{"id":"CVE-2024-40909","state":"PUBLISHED","title":"bpf: Fix a potential use-after-free in bpf_link_free()","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Fix a potential use-after-free in bpf_link_free()\n\nAfter commit 1a80dbcb2dba, bpf_link can be freed by\nlink->ops->dealloc_deferred, but the code still tests and uses\nlink->ops->dealloc afterward, which leads to a use-after-free as\nreported by syzbot. Actually, one of them should be sufficient, so\njust call one of them instead of both. Also add a WARN_ON() in case\nof any problematic implementation.","publishedAt":"2024-07-12T12:20:48.447Z","updatedAt":"2026-10-30T12:18:36.759Z","severity":{"score":7.8,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"Linux"},"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"ac48dc6ac9240f73bf08d29edf65c2deca93ee5d","status":"affected","lessThan":"e8ccda39b395169622855607085cdeef4d376e0f","versionType":"git"},{"version":"876941f533e7b47fc69977fc4551c02f2d18af97","status":"affected","lessThan":"91cff53136daeff50816b0baeafd38a6976f6209","versionType":"git"},{"version":"1a80dbcb2dbaf6e4c216e62e30fa7d3daa8001ce","status":"affected","lessThan":"fa97b8fed9896f1e89cb657513e483a152d4c382","versionType":"git"},{"version":"1a80dbcb2dbaf6e4c216e62e30fa7d3daa8001ce","status":"affected","lessThan":"2884dc7d08d98a89d8d65121524bb7533183a63a","versionType":"git"},{"version":"5d8d447777564b35f67000e7838e7ccb64d525c8","status":"affected","versionType":"git"},{"version":"6.6.26","status":"affected","lessThan":"6.6.35","versionType":"semver"},{"version":"6.8.5","status":"affected","lessThan":"6.9","versionType":"semver"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/syscall.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.9","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.9","versionType":"semver"},{"version":"6.6.35","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.9.6","status":"unaffected","lessThanOrEqual":"6.9.*","versionType":"semver"},{"version":"6.10","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/syscall.c"]}],"references":["https://git.kernel.org/stable/c/e8ccda39b395169622855607085cdeef4d376e0f","https://git.kernel.org/stable/c/91cff53136daeff50816b0baeafd38a6976f6209","https://git.kernel.org/stable/c/fa97b8fed9896f1e89cb657513e483a152d4c382","https://git.kernel.org/stable/c/2884dc7d08d98a89d8d65121524bb7533183a63a"],"weaknesses":[],"ingestedAt":"2026-10-30T12:34:06.950Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2024/40xxx/CVE-2024-40909.json","commit":"db8103c5921aac81d5d90efcf3745980dafabf49","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2024-40909","state":"PUBLISHED","datePublished":"2024-07-12T12:20:48.447Z","dateUpdated":"2026-10-30T12:18:36.759Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2024-07-12T12:17:45.580Z"},"containers":{"cna":{"title":"bpf: Fix a potential use-after-free in bpf_link_free()","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Fix a potential use-after-free in bpf_link_free()\n\nAfter commit 1a80dbcb2dba, bpf_link can be freed by\nlink->ops->dealloc_deferred, but the code still tests and uses\nlink->ops->dealloc afterward, which leads to a use-after-free as\nreported by syzbot. Actually, one of them should be sufficient, so\njust call one of them instead of both. Also add a WARN_ON() in case\nof any problematic implementation."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"ac48dc6ac9240f73bf08d29edf65c2deca93ee5d","status":"affected","lessThan":"e8ccda39b395169622855607085cdeef4d376e0f","versionType":"git"},{"version":"876941f533e7b47fc69977fc4551c02f2d18af97","status":"affected","lessThan":"91cff53136daeff50816b0baeafd38a6976f6209","versionType":"git"},{"version":"1a80dbcb2dbaf6e4c216e62e30fa7d3daa8001ce","status":"affected","lessThan":"fa97b8fed9896f1e89cb657513e483a152d4c382","versionType":"git"},{"version":"1a80dbcb2dbaf6e4c216e62e30fa7d3daa8001ce","status":"affected","lessThan":"2884dc7d08d98a89d8d65121524bb7533183a63a","versionType":"git"},{"version":"5d8d447777564b35f67000e7838e7ccb64d525c8","status":"affected","versionType":"git"},{"version":"6.6.26","status":"affected","lessThan":"6.6.35","versionType":"semver"},{"version":"6.8.5","status":"affected","lessThan":"6.9","versionType":"semver"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/syscall.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.9","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.9","versionType":"semver"},{"version":"6.6.35","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.9.6","status":"unaffected","lessThanOrEqual":"6.9.*","versionType":"semver"},{"version":"6.10","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/syscall.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/e8ccda39b395169622855607085cdeef4d376e0f"},{"url":"https://git.kernel.org/stable/c/91cff53136daeff50816b0baeafd38a6976f6209"},{"url":"https://git.kernel.org/stable/c/fa97b8fed9896f1e89cb657513e483a152d4c382"},{"url":"https://git.kernel.org/stable/c/2884dc7d08d98a89d8d65121524bb7533183a63a"}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","baseScore":7.8,"baseSeverity":"HIGH"},"scenarios":[{"lang":"en","value":"AV:L - The vulnerability is reached exclusively through the local `bpf()` syscall — creating a raw_tracepoint/kprobe_multi/uprobe_multi link and then closing its file descriptor. No network or remote-peer data is involved.\nAC:L - The attacker drives the free side directly and can repeat the create/close cycle in an unbounded loop across all CPUs while generating scheduling and RCU load to force preemption between `call_rcu()` and the stale `link->ops` read; syzbot triggered it in practice, so the window is reachable without relying on conditions outside attacker influence.\nPR:L - `bpf_token_capable()` grants BPF/PERFMON at `ns_capable()` level when a BPF token is delegated (kernel/bpf/token.c:17-28), so a process unprivileged in the init namespace inside a container can load these tracing programs and create the affected links; the same path is reachable by ordinary non-root service accounts holding only CAP_BPF+CAP_PERFMON, which is not administrative control of the host.\nUI:N - The entire sequence — link creation and fd close — is performed by the attacker's own process with no action required from any other user.\nS:U - The corruption and its consequences are confined to the kernel's own memory and privilege domain; no hypervisor, IOMMU, or other security-authority boundary is crossed.\nC:H - The use-after-free reads the `ops` pointer out of a freed slab object that the attacker can reallocate and fill via heap spraying, yielding an arbitrary kernel pointer dereference and an arbitrary-read primitive over kernel memory.\nI:H - After the stale `link->ops` read, the code performs `link->ops->dealloc(link)` — an indirect call through an attacker-controlled function pointer table, giving control-flow hijack and full kernel-integrity compromise.\nA:H - Even unweaponized, dereferencing and calling through a freed/recycled `ops` pointer produces a wild indirect branch and immediate kernel oops or panic, and the attacker can trigger it repeatedly."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-10-30T12:18:36.759Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.6.26","versionEndExcluding":"6.6.35"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.9","versionEndExcluding":"6.9.6"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.9","versionEndExcluding":"6.10"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.8.5"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}},"adp":[{"title":"CVE Program Container","references":[{"url":"https://git.kernel.org/stable/c/91cff53136daeff50816b0baeafd38a6976f6209","tags":["x_transferred"]},{"url":"https://git.kernel.org/stable/c/fa97b8fed9896f1e89cb657513e483a152d4c382","tags":["x_transferred"]},{"url":"https://git.kernel.org/stable/c/2884dc7d08d98a89d8d65121524bb7533183a63a","tags":["x_transferred"]}],"providerMetadata":{"shortName":"CVE","orgId":"af854a3a-2127-422b-91ae-364da2661108","dateUpdated":"2024-08-02T04:39:55.487Z"}},{"title":"CISA ADP Vulnrichment","metrics":[{"other":{"type":"ssvc","content":{"id":"CVE-2024-40909","role":"CISA Coordinator","options":[{"Exploitation":"none"},{"Automatable":"no"},{"Technical Impact":"partial"}],"version":"2.0.3","timestamp":"2024-09-10T17:06:09.099919Z"}}}],"providerMetadata":{"shortName":"CISA-ADP","orgId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","dateUpdated":"2024-09-11T17:34:37.410Z"}}]}}}