
PoC and detection tooling for CVE-2026-64507: demonstrates classic-BPF JIT spray, JIT memory reuse, and verifies the IBPB flush mitigation via kernel symbols and ftrace.
Demonstration and detection tooling for the Linux kernel hardening that flushes the indirect branch predictors (IBPB) when classic-BPF JIT memory is reused by the BPF program-pack allocator ("cBPF JIT spray hardening").
| CVE | CVE-2026-64507 (GHSA-mfjh-rff8-525v) |
| Component | Linux kernel — kernel/bpf/core.c + arch/x86/kernel/cpu/bugs.c |
| Introduced | with the BPF program-pack allocator (57631054fae6, v5.18) |
| Fixed (mainline) | a3af84b0fa00ead01fcd0e28b5d773ff25990a0d — merged for v7.2-rc2 |
| Fixed (stable) | 6.6.145, 6.12.97, 6.18.39, 7.1.4 (+ 6.16.y backport queue) |
| Related CVE | CVE-2026-64508 — infrastructure (bpf_arch_pred_flush static call/key, 96cce16e26dd02) |
| Series | "cBPF JIT spray hardening" by Pawan Gupta (Intel), 6 patches |
| Severity | hardening gap for Spectre-v2/BHI branch-target-injection (BTI) into JIT-sprayed BPF code |
TL;DR
$ make
$ ./poc info # is this kernel patched? is the flush active?
$ sudo ./poc all # full demonstration (spray + reuse + ftrace ground truth)
Verified in this repository on a patched kernel (7.2.6, flush active, IBPB confirmed per reuse) and on a genuinely vulnerable kernel (Debian 6.12.96 booted in QEMU/KVM, no flush at all). Real transcripts are in Verified results.
Since v5.18 the BPF JIT allocates small programs from 2 MiB executable packs
(bpf_prog_pack_alloc(), BPF_PROG_PACK_SIZE, 64-byte chunks). When a program is
freed its chunks return to the pack bitmap and are handed out again to later programs.
BPF immediates are copied verbatim into the generated machine code. A classic
(SO_ATTACH_FILTER) filter such as:
BPF_STMT(BPF_LD | BPF_IMM, 0xdeadbeef) /* -> b8 ef be ad de mov eax, 0xdeadbeef */
BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 0xcafebabe) /* -> 05 be ba fe ca add eax, 0xcafebabe */
compiles to executable kernel memory that contains the attacker-chosen bytes
ef be ad de … be ba fe ca verbatim (this PoC dumps them, see §6). An attacker who
controls many programs can therefore place large amounts of chosen instruction bytes
("JIT spray") at 64-byte-aligned addresses inside the execmem region. Classic socket
filters are the unprivileged attack surface the series targets.
On CPUs vulnerable to Spectre-v2 / branch-target injection (and to BHI), branch predictions are not tagged by privilege. An indirect branch can be misdirected speculatively into executable memory whose address the attacker groomed.
The pack allocator reuses freed chunks, so a new program can be placed at the very same address an older, attacker-controlled program occupied. Any predictor state (BTB/BHB entries) left behind by the old occupant — or trained by the attacker against it — still refers to that address, but the code there is now different. The upstream fix describes it as:
"When fresh code is written into space that a previous program occupied, an indirect jump into the new program can reuse a branch prediction left behind by the old one."
Flushing the indirect branch predictors (IBPB) before the reused memory is handed out removes that stale predictor state.
The 6-patch series (mainline hashes):
| # | Commit | Subject |
|---|---|---|
| 1 | 96cce16e26dd02a8678f1e87f88a4b5cdb63b995 | bpf: Support for hardening against JIT spraying (CVE-2026-64508) |
| 2 | a3af84b0fa00ead01fcd0e28b5d773ff25990a0d | x86/bugs: Enable IBPB flush on BPF JIT allocation (this CVE) |
| 3 | 0bb99f2cfaae6822d734d69722de30af823efdf3 | bpf: Restrict JIT predictor flush to cBPF |
| 4 | a23c1c5396a91680703360d1ee28a44657c503c4 | bpf: Skip redundant IBPB in pack allocator |
| 5 | a9b1f19a6a673ba06820898d0f1ad02883ea1639 | bpf: Prefer packs that won't trigger an IBPB flush on allocation |
| 6 | b72e29e0f7ee329d89f86db8700c8ea99b4a370a | bpf: Prefer dirty packs for eBPF allocations |
Mechanics (as merged, v7.2-rc2):
kernel/bpf/core.c gains a static key bpf_pred_flush_enabled and a static call
bpf_arch_pred_flush (default NULL → no CALL emitted).
bpf_prog_pack_alloc() invokes it when it hands out a chunk from a pack that "needs
a flush" (fresh pack, or a pack whose freed memory has become reusable) and only for
classic BPF programs (pr_warn_once for the >pack cBPF corner case).
eBPF allocations are steered to already-flushed packs and never flush.
arch/x86/kernel/cpu/bugs.c wires the static call to bpf_arch_ibpb(), which issues
on_each_cpu(write_ibpb/entry_ibpb) — one IBPB on every CPU — and prints at boot:
Spectre V2 : Enabling IBPB for BPF
The flush is enabled only when a genuine retpoline sequence is not active
(retpoline_seq_enabled()) and the CPU has IBPB. With retpoline, ring-0 indirect
predictions are already neutralized, so the flush is intentionally skipped.
bpf_arch_ibpb is a real symbol; its presence/absence in /proc/kallsyms is a cheap
patch indicator.CONFIG_RCU_LAZY=y (Debian default) the JIT frees are deferred by tens of
milliseconds, so allocation cycles that reuse memory behave observably differently
from tight loops whose frees are still pending.Demonstrated:
Enabling IBPB for BPF marker (info).spray, three independent evidence paths: eBPF-twin BPF_OBJ_GET_INFO_BY_FD,
/proc/kcore pack scan, bpf_jit_enable=2 log dump).reuse; RCU-aware probing, eBPF jited_ksyms).bpf_arch_ibpb counts the actual IBPB
broadcasts per reuse cycle: e.g. 30/30 or 19/20 on the patched test kernel
(a miss simply means a deferred free had not completed yet), and structurally
impossible on a vulnerable kernel (reuse, root).Not demonstrated (out of scope, honestly):
Legal/ethical note: run this only on systems you own or are authorized to test. It is non-destructive (filters are detached, sysctls are restored), but it deliberately manipulates executable kernel memory and branch predictors.