CVE-2026-139214: perf: Fix UAF in attach_task_ctx_data()
In the Linux kernel, the following vulnerability has been resolved:
perf: Fix UAF in attachtaskctxdata()
struct perfctxdata is RCU protected. In attachtaskctxdata(), the cmpxchg retry loop runs without holding rcureadlock(). If task->perfctxdata already holds a pointer (call it cd1), then trycmpxchg(&task->perfctxdata, &old, cd) fails and loads old = cd1. A concurrent thread running detachtaskctxdata() could free cd1 leading to UAF and further memory corruption when cd1 is reclaimed by another thread.
CPU 0: attachtaskctxdata() CPU 1: detachtaskctxdata() ----------------------------- ----------------------------- trycmpxchg(&task->perfctxdata, &old, cd2) -> fails; loads old = cd1
refcountdecandtest(&cd1->refcount) trycmpxchg(&task->perfctxdata, &cd1, NULL) perffreectxdatarcu(cd1) [ RCU grace period -> kfree(cd1) ]
refcountincnotzero(&old->refcount) -> UAF on freed cd1
Fix this by taking rcureadlock across the race window.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In Linux kernel perf's attach_task_ctx_data(), hold rcu_read_lock() across the cmpxchg retry-loop race window.