CVE-2026-139331: bpf, x86: Pass a trampoline's stack arguments by the calling convention
In the Linux kernel, the following vulnerability has been resolved:
bpf, x86: Pass a trampoline's stack arguments by the calling convention
A trampoline on a function of a program that can tail call keeps the tail call counter pointer by pushing rax after allocating its frame. When it calls the original function, for fexit, fmodret or fsession, the push sits between the stack arguments and the return address, which the x86-64 calling convention does not allow. For example, in
run() -> callstack() -> calleestack(a, b, c, d, e, f, g, h) run() -> subprogtail() -> bpftailcall()
calleestack() is not on the path to the tail call, so the verifier allows its stack arguments g and h. fexit on it builds, with T the trampoline's rbp:
T-120 h saveargs() T-128 g saveargs(), RSP after sub rsp, 128 T-136 tailcallcntptr push rax, RSP at the call T-144 return address call origcall
and calleestack() finds the counter pointer where g belongs, at 8(%rsp) on entry, and g where h belongs.
Keep the pointer in a slot of the frame instead, so that the stack arguments sit right above the return address again:
T-120 tailcallcntptr mov [rbp - 120], rax T-128 (pad to 16) T-136 h saveargs() T-144 g saveargs(), RSP at the call T-152 return address call origcall
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
Keep the trampoline tail-call counter pointer in a slot of the frame instead of pushing rax, so stack arguments remain above the return address according to the x86-64 calling convention.
Event History
Frequently Asked Questions
What conditions are required for this issue to occur?
The affected path involves an x86 BPF trampoline attached to a function in a program that can perform a tail call. The trampoline must call the original function in an fexit, fmod_ret, or fsession scenario where the original function receives stack-passed arguments.
Which function arguments are affected?
Arguments passed on the stack can be displaced because the trampoline pushes the tail-call counter pointer between those arguments and the return address. In the example, the callee reads the counter pointer as argument g and reads g as argument h.
Is every tail-call target affected?
No. The described case requires a function that is not on the path to the tail call, allowing the verifier to permit its stack arguments while the trampoline still preserves the tail-call counter.
What does the fix change?
The fix stores the tail-call counter pointer in a trampoline frame slot rather than pushing it onto the stack before calling the original function. This restores the x86-64 calling-convention layout, with stack arguments directly above the return address.