]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bpf: Check the helper function is valid in get_helper_proto
authorJiri Olsa <olsajiri@gmail.com>
Thu, 14 Aug 2025 20:06:55 +0000 (22:06 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 15 Aug 2025 09:16:56 +0000 (11:16 +0200)
kernel test robot reported verifier bug [1] where the helper func
pointer could be NULL due to disabled config option.

As Alexei suggested we could check on that in get_helper_proto
directly. Marking tail_call helper func with BPF_PTR_POISON,
because it is unused by design.

  [1] https://lore.kernel.org/oe-lkp/202507160818.68358831-lkp@intel.com

Reported-by: kernel test robot <oliver.sang@intel.com>
Reported-by: syzbot+a9ed3d9132939852d0df@syzkaller.appspotmail.com
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Paul Chaignon <paul.chaignon@gmail.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20250814200655.945632-1-jolsa@kernel.org
Closes: https://lore.kernel.org/oe-lkp/202507160818.68358831-lkp@intel.com
kernel/bpf/core.c
kernel/bpf/verifier.c

index 5d1650af899d048f73b33d1d075e6e374f1691f3..f8ac77d08ca72bb66e8d4591f39e5b857c5f4dce 100644 (file)
@@ -3024,7 +3024,10 @@ EXPORT_SYMBOL_GPL(bpf_event_output);
 
 /* Always built-in helper functions. */
 const struct bpf_func_proto bpf_tail_call_proto = {
-       .func           = NULL,
+       /* func is unused for tail_call, we set it to pass the
+        * get_helper_proto check
+        */
+       .func           = BPF_PTR_POISON,
        .gpl_only       = false,
        .ret_type       = RET_VOID,
        .arg1_type      = ARG_PTR_TO_CTX,
index c4f69a9e9af6904d21177c851bb059541ba98057..c89e2b1bc644b744cee4c72b29357f63f435fb34 100644 (file)
@@ -11354,7 +11354,7 @@ static int get_helper_proto(struct bpf_verifier_env *env, int func_id,
                return -EINVAL;
 
        *ptr = env->ops->get_func_proto(func_id, env->prog);
-       return *ptr ? 0 : -EINVAL;
+       return *ptr && (*ptr)->func ? 0 : -EINVAL;
 }
 
 static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn,