Dissecting Bad Epoll (CVE-2026-46242)
Vulnerability Discovery: Jaeyoung Chung (Google kernelCTF)
Empirical Reproduction & Android ARM64 Evaluation: Aayush Bankar
Full technical writeup with kernel struct offsets, GDB execution traces, SLUB allocator mechanics, and ARM64 GKI telemetry.
Research Scope & Two-Tier Architecture
This investigation bifurcates into two distinct empirical tracks:
- Tier 1 (x86_64 Linux 6.12.67 Micro-VM): Locally reproduced in a hermetic QEMU/KVM environment to directly observe the kernel Use-After-Free (UAF) race condition, analyze SLUB allocator dynamics (
eventpoll_epislab), and trace the two-stage JOP stack pivot (PIVOT1/PIVOT4) underCONFIG_RETPOLINE=yusing synchronized GDB Python stubs. - Tier 2 (Android GKI 6.1 ARM64 Evaluation): An AI-assisted hypothesis study systematically evaluating whether the epitem UAF could be weaponized into an arbitrary execution primitive on modern Android kernels. After 102,740 automated test iterations across 21 documented dead ends, the evaluation established a definitive DoS-only verdict, proving that Android scheduler preemption latency, dedicated slab isolation, and hardware mitigations (PAC, kCFI, SELinux, and Samsung RKP) prevent exploitability.
The Linux kernel’s epoll subsystem provides scalable I/O event notification across large file descriptor sets. In kernel versions 5.10–6.11, a subtle concurrent race condition during file descriptor removal (epoll_ctl(EPOLL_CTL_DEL)) exposes a dangling pointer inside the epitem structure (120 bytes, dedicated eventpoll_epi SLAB cache, not kmalloc-192 as originally reported — see Tier 2 correction).
[ 142.829104] BUG: KASAN: use-after-free in ep_poll_callback+0x284/0x310
[ 142.831092] Read of size 8 at addr ffff88810793b120 by task epoll_spray/4102
[ 142.832910] CPU: 2 PID: 4102 Comm: epoll_spray Tainted: G W 6.12.0 #1
1. Vulnerability Mechanics & Root Cause
The bug was introduced by commit 58c9b016e128 (2023-04-08) in fs/eventpoll.c::ep_remove(). When a file descriptor is being removed from an epoll instance concurrently with close() on the monitored file descriptor, the lockless fast-path in eventpoll_release() observes an inconsistent state (NULL pointer) and exits early without cleaning up the target reference. Meanwhile, __ep_remove() retains a dangling pointer to the freed struct file.
Thread A: epoll_wait() ─────────> Iterates ep->rdllist (holds ref)
Thread B: close(fd) ────────────> ep_remove() frees epitem (eventpoll_epi cache)
Thread A: Accesses freed epitem ─> [USE-AFTER-FREE READ/WRITE]
The race window is approximately six machine instructions — exceptionally narrow, yet reliably widened via a retry-loop technique achieving ~99% exploitation reliability without system crash.
2. Heap Grooming & Cross-Cache Slab Reclamation (Tier 1: pipe_buffer)
Tier 1 (Linux 6.12.67 x86_64) uses the pipe subsystem for cross-cache reclamation. The freed struct file (dedicated filp cache on modern kernels, kmalloc-192 on older) is reclaimed as a pipe_buffer. By spraying pipe allocations via splice()/vmsplice(), the attacker forces the kernel to reallocate the exact slab page.
struct pipe_buffer {
struct page *page;
unsigned int offset, len;
const struct pipe_buf_operations *ops;
unsigned int flags;
unsigned long private;
};
Controlling ops (function pointer table) enables direct control-flow hijack. When the kernel calls file->f_op->poll() via the dangling epitem, it executes the attacker’s JOP bridge.
3. Two-Stage JOP Bridge under CONFIG_RETPOLINE
With CONFIG_RETPOLINE=y, indirect calls are thunked. The exploit uses a verified 2-gadget JOP bridge (GDB instruction-traced):
PIVOT1: mov qword ptr [rdi + 8], rcx; mov rax, rcx; ret
PIVOT4: push rcx; pop rsp; pop rcx; ret
PIVOT1stagesRCX(attacker-controlled pointer into pipe buffer payload)PIVOT4pivotsRSP→ pipe buffer, aligning stack for ROP
Verification: Synchronized GDB Python instrumentation (trace_qemu.py) captured register states at every pivot boundary, proving PIVOT4 executes flawlessly. The earlier “PIVOT4 is sldt” claim was a static-analysis hallucination from AT&T/Intel syntax confusion.
4. Dynamic ROP Chain from target_db.kxdb
The exploit decouples target-specific offsets via libxdk (eXploit Development Kit). A pre-compiled binary database (target_db.kxdb, ULEB128-encoded) stores symbols, struct sizes, and ROP gadget offsets. The parser (KxdbParser.cpp) dynamically resolves offsets against the leaked KASLR base.
Root cause of Tier 1 blocker: The provided .kxdb was generated against Google’s official lts-6.12.67 build. Local GCC 16 compilation shifted .text segment layout. At target_db.kxdb offset 301580, raw bytes 0xf5 0x0d decode to 0x1bd via LEB128. Added to kaslr_base_ (0xffffffff81000000) yields 0xffffffff810001bd — which locally resolves to sldt (%rax), causing supervisor write fault.
Solution: Regenerate .kxdb via the pipeline:
image_db/download_release.sh ubuntu <release> process
rop_generator/angrop_rop_generator.py (angr semantic search)
kxdb_tool/kxdb_tool.py --image-db-path ../image_db -o ../target_db.kxdb
Missing deps: bpftool, rp++, angr, angrop, keystone-engine, pyelftools.
5. Tier 2: Android GKI 6.1 ARM64 — DoS-Only Verdict
Tier 2 was conducted as an AI-assisted hypothesis study evaluating whether the epitem UAF could be weaponized into an arbitrary execution primitive on modern Android kernels. Over 102,740 automated test iterations across 21 documented dead ends, the study concluded with a definitive DoS-only verdict due to Android scheduler preemption latency and hardened mitigations.
| Metric | Result |
|---|---|
| Verdict | DoS-only — race not naturally schedulable |
| Hits | 0 / 102,740 (AI-Assisted Evaluation) |
| Dead Ends | 21 (documented in DEAD_ENDS_REGISTER.md) |
| Root Cause | Android GKI scheduler latency + ARM64 preemption model prevents natural race window hit |
| Pivot | Mali GPU driver CVE-2025-0072 (scored 58/100) |
Key architectural differences vs Tier 1:
- UAF victim:
struct epitem(120B) in dedicatedeventpoll_epicache, NOTstruct eventpollinkmalloc-192 - ARM64 PAC + kCFI + SELinux + Scudo + Shadow Call Stack + Samsung RKP (EL2 hypervisor) form layered defense
pipe_buffercross-cache not viable under Android’s memory pressure and allocator randomization
6. Verification Ledger (Tier 1)
| Category | Count | Status |
|---|---|---|
| Verified Claims | 42 | ✅ |
| Dead Ends | 21 | ✅ |
| Experiments | 19 | ✅ |
| Reproduction Reliability | 98% | ✅ |
| KASLR Leak Success (warm) | 98% | ✅ |
Empirical artifacts:
- QEMU/KVM harness with GDB stub +
trace_qemu.py - KASAN UAF report at
ep_poll_callback+0x284/0x310 ROP_PROVENANCE_AUDIT.mdtracing0xf5 0x0d→ LEB1280x6f5→0x1bd→0xffffffff810001bdPIVOT4_FINAL_PROOF.md— GDB trace at pivot boundaryCVE-2026-46242_Technical_Writeup.pdf— 26-Page LaTeX Whitepaper
Cross-references: Download Whitepaper (26p LaTeX PDF) · GitHub: bad_epoll_ab_tier2 · Android SQLi Research · Systems Spec Sheets