]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bpf: Move bpf_jit_get_prog_name() to core.c
authorPuranjay Mohan <puranjay@kernel.org>
Thu, 24 Jul 2025 12:02:53 +0000 (12:02 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Sat, 26 Jul 2025 19:26:51 +0000 (21:26 +0200)
bpf_jit_get_prog_name() will be used by all JITs when enabling support
for private stack. This function is currently implemented in the x86
JIT.

Move the function to core.c so that other JITs can easily use it in
their implementation of private stack.

Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/bpf/20250724120257.7299-2-puranjay@kernel.org
arch/x86/net/bpf_jit_comp.c
include/linux/filter.h
kernel/bpf/core.c

index 40e1b3b9634fec27c81fb7899d87515add500314..7e3fca1646203c1d5d36392260bc4ee071b34b15 100644 (file)
@@ -3501,13 +3501,6 @@ int arch_prepare_bpf_dispatcher(void *image, void *buf, s64 *funcs, int num_func
        return emit_bpf_dispatcher(&prog, 0, num_funcs - 1, funcs, image, buf);
 }
 
-static const char *bpf_get_prog_name(struct bpf_prog *prog)
-{
-       if (prog->aux->ksym.prog)
-               return prog->aux->ksym.name;
-       return prog->aux->name;
-}
-
 static void priv_stack_init_guard(void __percpu *priv_stack_ptr, int alloc_size)
 {
        int cpu, underflow_idx = (alloc_size - PRIV_STACK_GUARD_SZ) >> 3;
@@ -3531,7 +3524,7 @@ static void priv_stack_check_guard(void __percpu *priv_stack_ptr, int alloc_size
                if (stack_ptr[0] != PRIV_STACK_GUARD_VAL ||
                    stack_ptr[underflow_idx] != PRIV_STACK_GUARD_VAL) {
                        pr_err("BPF private stack overflow/underflow detected for prog %sx\n",
-                              bpf_get_prog_name(prog));
+                              bpf_jit_get_prog_name(prog));
                        break;
                }
        }
index eca229752cbef8f67d576a705e562d65f0de871b..5cc7a82ec83224ddad4e07b4d71def483bc47ded 100644 (file)
@@ -1278,6 +1278,8 @@ int bpf_jit_get_func_addr(const struct bpf_prog *prog,
                          const struct bpf_insn *insn, bool extra_pass,
                          u64 *func_addr, bool *func_addr_fixed);
 
+const char *bpf_jit_get_prog_name(struct bpf_prog *prog);
+
 struct bpf_prog *bpf_jit_blind_constants(struct bpf_prog *fp);
 void bpf_jit_prog_release_other(struct bpf_prog *fp, struct bpf_prog *fp_other);
 
index 61613785bdd0f53f444f5fe2f3544ba4aed8e126..29c0225c14aa92b8e72eb4c6a2cd26d5b375d857 100644 (file)
@@ -1297,6 +1297,13 @@ int bpf_jit_get_func_addr(const struct bpf_prog *prog,
        return 0;
 }
 
+const char *bpf_jit_get_prog_name(struct bpf_prog *prog)
+{
+       if (prog->aux->ksym.prog)
+               return prog->aux->ksym.name;
+       return prog->aux->name;
+}
+
 static int bpf_jit_blind_insn(const struct bpf_insn *from,
                              const struct bpf_insn *aux,
                              struct bpf_insn *to_buff,