
Analysis and C reproducer for CVE-2026-46242, a Linux kernel eventpoll ep_remove() race use-after-free in nested epoll, with patch diff and KASAN verification steps.
Reproducer / PoC (trigger-verification type): Linux & Android (NDK) This repository is intended solely for verifying patch status and for research/learning on your own test devices; it contains no privilege-escalation/exploitation primitives.
| 字段 | 内容 |
|---|---|
| CVE ID | CVE-2026-46242 |
| 标题 | eventpoll: fix ep_remove struct eventpoll / struct file UAF |
| 类型 | Use-After-Free(CWE-416),竞态条件 |
| CNA | kernel.org(Linux CNA) |
| CVSS v3.1 | 7.8 High — CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H |
| CISA KEV | 未收录(截至 2026-10) |
| 公开日期 | 2026-05-30(预留 2026-05-13;oss-security 披露 2026-07-08) |
| 修复提交(mainline) | a6dc643c69311677c574a0f17a3f4d66a5f3744b |
| 引入问题提交(Fixes:) | 58c9b016e128 (v6.4, 2023) — "epoll: use refcount to reduce ep_mutex contention" |
| 修复者 | Christian Brauner <[email protected]> |
| 报告者 | Jaeyoung Chung <[email protected]> |
| 影响文件 | fs/eventpoll.c(仅一个文件,+10/−6 行) |
The vulnerability was introduced in v6.4 (2023-06). Note two special windows: the introducing commit was later backported into 5.15 / 6.1 stable, so these two older LTS branches are affected only within very narrow version ranges:
| Branch | Affected | Fixed version (≥) | Stable fix commit |
|---|---|---|---|
| 5.10 LTS | Not affected | — | — |
| 5.15 LTS | 5.15.209 ~ 5.15.221 (introduced by backport) | 5.15.222 | a10fbbe74e1c |
| 6.1 LTS | 6.1.175 ~ 6.1.177 (introduced by backport) | 6.1.178 | 3e1144d2515d |
| 6.6 LTS | 6.4 ~ 6.6.143 | 6.6.144 | 2de4db145b29 |
| 6.12 LTS | ~ 6.12.94 | 6.12.95 | 9324de74a3a5 |
| 6.18 | ~ 6.18.32 | 6.18.33 | ef4ca02e9536 |
| 7.0 | ~ 7.0.9 | 7.0.10 | ced39b6a8062 |
| mainline | < 7.1 | 7.1 | a6dc643c6931 |
Among Android GKI kernels, the 6.6 / 6.12 branches fall within the affected range (e.g., the 6.6 GKI on the Pixel 10 series); 5.10 GKI is not affected, and 6.1 GKI is affected only when the kernel happens to fall within the 6.1.175~6.1.177 window. The mainline fix commit is dated 2026-04-23, and the CVE was published on 2026-05-30. Devices with an earlier SPL most likely have not merged this fix, so please rely on the kernel version number (adb shell cat /proc/version and getprop ro.build.version.security_patch).
Disambiguation: Some articles online refer to this CVE as "Bad Epoll"; that codename does not match the official record and is a misnomer (there are also rumors confusing it with CVE-2026-43499). Refer to the CVE record and the kernel.org commit as authoritative.
file->f_epepoll allows nested monitoring: epoll_ctl(e1, EPOLL_CTL_ADD, e2, ...) can attach another epoll fd e2 into e1. In this case, the kernel creates an epitem (epi) for the struct file of e2 and links epi->fllink into the ->refs hash list embedded in the monitored eventpoll (that is, e2's own struct eventpoll).
struct file->f_ep points to the eventpoll associated with that file; eventpoll_release_file() (slow path) sets f_ep to NULL under f_lock and detaches all related epis, mutually excluding with ep_remove() via f_lock.
ep_remove() (triggered by EPOLL_CTL_DEL or by closing the outer epoll, via ep_remove_file()) under the protection of file->f_lock first clears file->f_ep, but then continues to use @file within the critical section (is_file_epoll(), hlist_del_rcu() via the list head, spin_unlock).
Meanwhile, a concurrent __fput() on another CPU takes the eventpoll_release() fastpath, observes a transient f_ep == NULL within this window, and therefore skips eventpoll_release_file(), proceeding directly to f_op->release / file_free():
ep_remove() 线程 close(inner_epfd) → __fput()
ep_remove_file()
spin_lock(&file->f_lock)
file->f_ep = NULL; __fput() fastpath:
... if (file->f_ep) // 观察到 NULL
is_file_epoll(file) // 仍用 file → 跳过 eventpoll_release_file()
hlist_del_rcu(&epi->fllink) f_op->release = ep_eventpoll_release()
*pprev = next // 写已释放内存! → ep_clear_and_put() → ep_free()
spin_unlock(&file->f_lock) kfree(eventpoll) // ← 释放
Why it is a UAF write: In the epoll-watches-epoll scenario, the ->refs list head embedded in the freed struct eventpoll is exactly the location pointed to by epi->fllink.pprev, and *pprev = next in hlist_del_rcu() writes a pointer value into freed kmalloc-192 memory.
Making matters worse: struct file belongs to SLAB_TYPESAFE_BY_RCU, so the slab slot for @file may be reclaimed and reused by alloc_empty_file()—f_lock and f_ep are reinitialized, while ep_remove() nominally still holds that lock. Ultimately this can result in an attacker-controlled kmem_cache_free() targeting the wrong slab cache.
At the top of ep_remove(), use epi_fget() to pin @file, and use whether the pin succeeds as the gate for entering the critical section:
@file reference count cannot reach zero, __fput() is blocked, and the watched eventpoll also stays alive until hlist_del_rcu() and the use of f_lock are complete, closing both UAFs at once;__fput() is already in progress. Because the bailout occurs before f_ep is cleared, the release path will take the eventpoll_release_file() slow path and block on ep->mtx, and the orphan epi will be cleaned up by it;eventpoll_release_file(), so the redundant epi->dying recheck under f_lock is removed (the lockless READ_ONCE(epi->dying) fast path is retained).See patches/a6dc643c6931.patch for the full diff.
poc/ provides a race trigger: multiple groups of threads run high-intensity loops
e1 and an inner epoll e2, and use epoll_ctl(e1, ADD, e2) to establish nested watching (the vulnerability precondition);epoll_ctl(e1, EPOLL_CTL_DEL, e2) — this goes through ep_remove();close(e2) — this goes through __fput() → eventpoll_release() fastpath.When the instantaneous window in which ep_remove_file() clears f_ep happens to collide with the fastpath check in __fput(), hlist_del_rcu() on an unpatched kernel writes into eventpoll memory that has already been freed by ep_free(). With a KASAN kernel, reports such as BUG: KASAN: use-after-free in ep_remove / hlist_del_rcu or slab-out-of-bounds in ep_free can be observed; without KASAN, it usually manifests as an occasional oops/panic or silent heap corruption.