Skip to content

Commit e4414b0

Browse files
olsajiriborkmann
authored andcommitted
bpf: Check the helper function is valid in get_helper_proto
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/[email protected] Reported-by: kernel test robot <[email protected]> Reported-by: [email protected] Suggested-by: Alexei Starovoitov <[email protected]> Signed-off-by: Jiri Olsa <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Paul Chaignon <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected] Closes: https://lore.kernel.org/oe-lkp/[email protected]
1 parent 2b986b9 commit e4414b0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

kernel/bpf/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3024,7 +3024,10 @@ EXPORT_SYMBOL_GPL(bpf_event_output);
30243024

30253025
/* Always built-in helper functions. */
30263026
const struct bpf_func_proto bpf_tail_call_proto = {
3027-
.func = NULL,
3027+
/* func is unused for tail_call, we set it to pass the
3028+
* get_helper_proto check
3029+
*/
3030+
.func = BPF_PTR_POISON,
30283031
.gpl_only = false,
30293032
.ret_type = RET_VOID,
30303033
.arg1_type = ARG_PTR_TO_CTX,

kernel/bpf/verifier.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11354,7 +11354,7 @@ static int get_helper_proto(struct bpf_verifier_env *env, int func_id,
1135411354
return -EINVAL;
1135511355

1135611356
*ptr = env->ops->get_func_proto(func_id, env->prog);
11357-
return *ptr ? 0 : -EINVAL;
11357+
return *ptr && (*ptr)->func ? 0 : -EINVAL;
1135811358
}
1135911359

1136011360
static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn,

0 commit comments

Comments
 (0)