{"id":"CVE-2025-40319","state":"PUBLISHED","title":"bpf: Sync pending IRQ work before freeing ring buffer","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Sync pending IRQ work before freeing ring buffer\n\nFix a race where irq_work can be queued in bpf_ringbuf_commit()\nbut the ring buffer is freed before the work executes.\nIn the syzbot reproducer, a BPF program attached to sched_switch\ntriggers bpf_ringbuf_commit(), queuing an irq_work. If the ring buffer\nis freed before this work executes, the irq_work thread may accesses\nfreed memory.\nCalling `irq_work_sync(&rb->work)` ensures that all pending irq_work\ncomplete before freeing the buffer.","publishedAt":"2025-12-08T00:46:46.448Z","updatedAt":"2026-10-15T22:02:43.846Z","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":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"47626748a2a00068dbbd5836d19076637b4e235b","versionType":"git"},{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"de2ce6b14bc3e565708a39bdba3ef9162aeffc72","versionType":"git"},{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"e1828c7a8d8135e21ff6adaaa9458c32aae13b11","versionType":"git"},{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"6451141103547f4efd774e912418a3b4318046c6","versionType":"git"},{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"10ca3b2eec384628bc9f5d8190aed9427ad2dde6","versionType":"git"},{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"430e15544f11f8de26b2b5109c7152f71b78295e","versionType":"git"},{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"4e9077638301816a7d73fa1e1b4c1db4a7e3b59c","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/ringbuf.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.8","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.8","versionType":"semver"},{"version":"5.10.247","status":"unaffected","lessThanOrEqual":"5.10.*","versionType":"semver"},{"version":"5.15.197","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"6.1.159","status":"unaffected","lessThanOrEqual":"6.1.*","versionType":"semver"},{"version":"6.6.117","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.58","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.17.8","status":"unaffected","lessThanOrEqual":"6.17.*","versionType":"semver"},{"version":"6.18","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/ringbuf.c"]}],"references":["https://git.kernel.org/stable/c/47626748a2a00068dbbd5836d19076637b4e235b","https://git.kernel.org/stable/c/de2ce6b14bc3e565708a39bdba3ef9162aeffc72","https://git.kernel.org/stable/c/e1828c7a8d8135e21ff6adaaa9458c32aae13b11","https://git.kernel.org/stable/c/6451141103547f4efd774e912418a3b4318046c6","https://git.kernel.org/stable/c/10ca3b2eec384628bc9f5d8190aed9427ad2dde6","https://git.kernel.org/stable/c/430e15544f11f8de26b2b5109c7152f71b78295e","https://git.kernel.org/stable/c/4e9077638301816a7d73fa1e1b4c1db4a7e3b59c"],"weaknesses":[],"ingestedAt":"2026-10-29T20:09:09.358Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2025/40xxx/CVE-2025-40319.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2025-40319","state":"PUBLISHED","datePublished":"2025-12-08T00:46:46.448Z","dateUpdated":"2026-10-15T22:02:43.846Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2025-04-16T07:20:57.186Z"},"containers":{"cna":{"title":"bpf: Sync pending IRQ work before freeing ring buffer","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Sync pending IRQ work before freeing ring buffer\n\nFix a race where irq_work can be queued in bpf_ringbuf_commit()\nbut the ring buffer is freed before the work executes.\nIn the syzbot reproducer, a BPF program attached to sched_switch\ntriggers bpf_ringbuf_commit(), queuing an irq_work. If the ring buffer\nis freed before this work executes, the irq_work thread may accesses\nfreed memory.\nCalling `irq_work_sync(&rb->work)` ensures that all pending irq_work\ncomplete before freeing the buffer."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"47626748a2a00068dbbd5836d19076637b4e235b","versionType":"git"},{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"de2ce6b14bc3e565708a39bdba3ef9162aeffc72","versionType":"git"},{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"e1828c7a8d8135e21ff6adaaa9458c32aae13b11","versionType":"git"},{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"6451141103547f4efd774e912418a3b4318046c6","versionType":"git"},{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"10ca3b2eec384628bc9f5d8190aed9427ad2dde6","versionType":"git"},{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"430e15544f11f8de26b2b5109c7152f71b78295e","versionType":"git"},{"version":"457f44363a8894135c85b7a9afd2bd8196db24ab","status":"affected","lessThan":"4e9077638301816a7d73fa1e1b4c1db4a7e3b59c","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/ringbuf.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.8","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.8","versionType":"semver"},{"version":"5.10.247","status":"unaffected","lessThanOrEqual":"5.10.*","versionType":"semver"},{"version":"5.15.197","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"6.1.159","status":"unaffected","lessThanOrEqual":"6.1.*","versionType":"semver"},{"version":"6.6.117","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.58","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.17.8","status":"unaffected","lessThanOrEqual":"6.17.*","versionType":"semver"},{"version":"6.18","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/ringbuf.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/47626748a2a00068dbbd5836d19076637b4e235b"},{"url":"https://git.kernel.org/stable/c/de2ce6b14bc3e565708a39bdba3ef9162aeffc72"},{"url":"https://git.kernel.org/stable/c/e1828c7a8d8135e21ff6adaaa9458c32aae13b11"},{"url":"https://git.kernel.org/stable/c/6451141103547f4efd774e912418a3b4318046c6"},{"url":"https://git.kernel.org/stable/c/10ca3b2eec384628bc9f5d8190aed9427ad2dde6"},{"url":"https://git.kernel.org/stable/c/430e15544f11f8de26b2b5109c7152f71b78295e"},{"url":"https://git.kernel.org/stable/c/4e9077638301816a7d73fa1e1b4c1db4a7e3b59c"}],"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 through the `bpf()` syscall — creating a ringbuf map, loading a program that calls `bpf_ringbuf_output`/`submit`, and closing the fds to drive `ringbuf_map_free()`. There is no path for a remote peer to load BPF programs, so local system access is required.\nAC:L - The attacker controls both sides of the race: he triggers `bpf_ringbuf_commit()` on demand (loopback packet into his own socket filter, using `BPF_RB_FORCE_WAKEUP` to guarantee `irq_work_queue()` on every commit) and separately triggers the free by detaching and closing the map/prog fds, looping unboundedly. On PREEMPT_RT the work is deferred to the `irq_workd` kthread and on architectures without `arch_irq_work_has_interrupt()` to the next tick, widening the window to milliseconds; syzbot both reproduced the bug and confirmed the fix.\nPR:L - `BPF_MAP_TYPE_RINGBUF`/`USER_RINGBUF` are listed as unprivileged map types in `map_create()`, the ringbuf helpers sit above the `CAP_BPF` gate in `bpf_base_func_proto()`, `BPF_PROG_TYPE_SOCKET_FILTER` is exempt from the CAP_BPF prog-load check, and `SO_ATTACH_BPF` has no capability check — so an ordinary unprivileged user can build the entire chain on the upstream default `unprivileged_bpf_disabled=0`.\nUI:N - The attacker performs every step himself — map creation, program load, socket attach, packet injection, and fd close — with no victim action or cooperating process required.\nS:U - The use-after-free corrupts kernel memory and the per-CPU irq_work list within the same security authority; no VM, IOMMU, or sandbox boundary is crossed.\nC:H - `irq_work_single()` and `bpf_ringbuf_notify()`/`wake_up_all()` read `work->node.llist`, `work->func`, `work->irqwait.task`, and the `waitq` list head out of freed memory, and the vmalloc VA range can be reclaimed with a large vmalloc-backed `BPF_MAP_TYPE_ARRAY` whose contents the attacker sets — turning the dangling traversal into an arbitrary kernel-memory read/disclosure primitive.\nI:H - The irq_work core performs `atomic_set()`/`atomic_cmpxchg()` writes into the freed object and an indirect call `work->func(work)` on a pointer read from it, while `wake_up_all()` adds `list_del_init()` unlink writes and a second function-pointer call — after VA-range reclamation with controlled data this is a direct control-flow hijack and arbitrary-write path to privilege escalation.\nA:H - This is a use-after-free reported by syzbot as a KASAN splat; in the common case the irq_work dereferences an already-unmapped vmalloc address from hardirq or the `irq_workd` kthread, producing an unhandled page fault and kernel panic, and it can be re-triggered in a loop."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-08-05T12:09:31.491Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.8","versionEndExcluding":"5.10.247"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.8","versionEndExcluding":"5.15.197"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.8","versionEndExcluding":"6.1.159"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.8","versionEndExcluding":"6.6.117"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.8","versionEndExcluding":"6.12.58"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.8","versionEndExcluding":"6.17.8"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.8","versionEndExcluding":"6.18"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}},"adp":[{"title":"CISA ADP Vulnrichment","metrics":[{"other":{"type":"ssvc","content":{"id":"CVE-2025-40319","role":"CISA Coordinator","options":[{"Exploitation":"none"},{"Automatable":"no"},{"Technical Impact":"total"}],"version":"2.0.3","timestamp":"2026-10-15T21:59:12.535828Z"}}}],"providerMetadata":{"shortName":"CISA-ADP","orgId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","dateUpdated":"2026-10-15T22:02:43.846Z"}}]}}}