CVE-2026-89580: bpf: Disable preemption in __bpf_get_stack
In the Linux kernel, the following vulnerability has been resolved:
bpf: Disable preemption in bpfgetstack
getperfcallchain() returns a per-CPU perfcallchainentry buffer and releases its recursion slot via putcallchainentry() before returning, so nothing keeps the entry reserved while bpfgetstack() consumes it below.
A preemptible BPF program (e.g. a non-sleepable raw tracepoint program on a PREEMPT kernel, which runs under migratedisable() but not preemptdisable()) can be scheduled out between obtaining the entry and the copy. Another task scheduled on the same CPU then reuses the same per-CPU buffer and overwrites trace->nr with a larger value. copylen is then computed from the inflated trace->nr and can exceed the caller's buffer, causing an out-of-bounds write in the memcpy() and in the buildid path.
The rcureadlock() taken here alone does not prevent this. It is only taken on the mayfault path, and under CONFIGPREEMPTRCU it does not disable preemption; it merely keeps perf's callchain buffer array alive (freed via callrcu()) and does nothing to stop another task from reusing the entry.
Disable preemption around obtaining the callchain entry and copying it into the caller's buffer, so the entry cannot be reused underneath us and trace->nr stays bounded by maxdepth. Build ID resolution may fault and is therefore deferred until after preemption is re-enabled; by then the instruction pointers have already been copied into buf, so it operates only on that private copy. Note, preemptdisable() also subsumes the buffer-lifetime guarantee the rcureadlock() provided, since a preempt-disabled section is an RCU read-side critical section for the callchain buffers' callrcu() reclaim.
[ changed Fixes: commit ]
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Configuration
Apply the kernel fix "bpf: Disable preemption in __bpf_get_stack" so preemption is disabled around obtaining the callchain entry and copying, preventing call_rcu() reuse from causing an out-of-bounds memcpy.
Linux kernel (bpf) __bpf_get_stack preemption = Disable preemption around obtaining the callchain entry and copying
Event History
Frequently Asked Questions
Which systems are exposed to this issue?
Systems running a PREEMPT Linux kernel with preemptible BPF programs are exposed. The description specifically identifies non-sleepable raw tracepoint BPF programs, which run under migrate_disable() without preempt_disable(), as an example.
What conditions are needed to trigger the out-of-bounds write?
A preemptible BPF program must be scheduled out after it obtains the per-CPU perf callchain entry but before it copies from it. Another task must then run on the same CPU and reuse the buffer with a larger trace->nr value, causing the calculated copy length to exceed the caller buffer.
Does rcu_read_lock() mitigate the race?
No. It only protects the perf callchain buffer array from being freed on the may_fault path; under CONFIG_PREEMPT_RCU it does not disable preemption or prevent another task from reusing the per-CPU entry.
What does the fix change?
The fix disables preemption while obtaining the callchain entry and copying its contents. This keeps another task on the same CPU from reusing and overwriting the per-CPU callchain buffer during the copy.