]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bpf: save subprogram name in bpf_subprog_info
authorEduard Zingerman <eddyz87@gmail.com>
Fri, 10 Apr 2026 20:55:53 +0000 (13:55 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 10 Apr 2026 22:01:56 +0000 (15:01 -0700)
Subprogram name can be computed from function info and BTF, but it is
convenient to have the name readily available for logging purposes.
Update comment saying that bpf_subprog_info->start has to be the first
field, this is no longer true, relevant sites access .start field
by it's name.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20260410-patch-set-v4-2-5d4eecb343db@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf_verifier.h
kernel/bpf/verifier.c

index 15f7f9f35be98f6f30c46cdf03cf5c0249a8ac38..cec6054d6333621f80b91b293fc71819503465d4 100644 (file)
@@ -664,7 +664,7 @@ enum priv_stack_mode {
 };
 
 struct bpf_subprog_info {
-       /* 'start' has to be the first field otherwise find_subprog() won't work */
+       const char *name; /* name extracted from BTF */
        u32 start; /* insn idx of function entry point */
        u32 linfo_idx; /* The idx to the main_prog->aux->linfo */
        u32 postorder_start; /* The idx to the env->cfg.insn_postorder */
index c422f1142b99fab80f453910a858c3519a3014c4..de63e5b17c92770c5a3f26bb2f42461e91e6d815 100644 (file)
@@ -19797,6 +19797,7 @@ static int check_btf_func(struct bpf_verifier_env *env,
                        goto err_free;
                }
 
+               env->subprog_info[i].name = btf_name_by_offset(btf, type->name_off);
                bpfptr_add(&urecord, urec_size);
        }