CVE-2026-139635: bpf: Keep target extended until its last freplace link detaches
In the Linux kernel, the following vulnerability has been resolved:
bpf: Keep target extended until its last freplace link detaches
The isextended / progarraymembercnt protocol introduced by commit d6083f040d5d ("bpf: Prevent tailcall infinite loop caused by freplace") keeps a prog extended by a freplace program out of progarray maps, and vice versa: once a tail call re-enters an extended subprogram, its tailcallcnt resets on every execution and the loop never terminates.
But isextended is a plain boolean, while one target prog can carry several freplace links at the same time, one on its entry and one on a global subprogram. bpftrampolineunlinkprog() cleared isextended whenever any freplace link detached, so detaching one of two links re-armed the unbounded loop through the remaining one.
Replace the isextended boolean with a count of the freplace links attached to each target prog, so the target stays extended until its last link detaches. Also rename bpffreplacechecktgtprog() to bpffreplacelinktgtprog(), as the helper has never been a pure check: it reserves the target prog on success.
Affected Software
Event History
Frequently Asked Questions
What conditions are required to trigger the unbounded tail-call loop?
A target BPF program must have multiple freplace links attached, including links that can target its entry and a global subprogram. The issue is triggered when one freplace link is detached while another remains, allowing the target to be treated as no longer extended and re-entered through a tail call.
What is the practical impact of detaching only one freplace link?
Detaching any one freplace link could clear the target program's extended state even when other freplace links were still attached. A tail call that re-enters the still-extended subprogram could then repeatedly reset its tail-call counter, causing a loop that does not terminate.
How does the fix prevent the issue?
The fix replaces the single is_extended boolean with a count of freplace links attached to each target program. The target remains marked extended until its final freplace link is detached.