]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Disable private stack for x86_64 if stack arguments used
authorYonghong Song <yonghong.song@linux.dev>
Wed, 13 May 2026 04:51:14 +0000 (21:51 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 13 May 2026 16:27:31 +0000 (09:27 -0700)
Other architectures like arm64, riscv, etc. have enough register
and for them private stack can be used together with
stack arguments.

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20260513045114.2392291-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c

index a10cc045057dbc17628971f63375475fcf70ff06..82b9531f87f67a58c1ec0e2821902f9973597bed 100644 (file)
@@ -5163,7 +5163,10 @@ process_func:
        }
 
        subprog_depth = round_up_stack_depth(env, subprog[idx].stack_depth);
-       if (priv_stack_supported) {
+       if (IS_ENABLED(CONFIG_X86_64) && subprog[idx].stack_arg_cnt) {
+               /* x86-64 uses R9 for both private stack frame pointer and arg6. */
+               subprog[idx].priv_stack_mode = NO_PRIV_STACK;
+       } else if (priv_stack_supported) {
                /* Request private stack support only if the subprog stack
                 * depth is no less than BPF_PRIV_STACK_MIN_SIZE. This is to
                 * avoid jit penalty if the stack usage is small.