Skip to content

Commit

Permalink
bpf: fix visit_insn()'s detection of BPF_FUNC_timer_set_callback helper
Browse files Browse the repository at this point in the history
It's not correct to assume that any BPF_CALL instruction is a helper
call. Fix visit_insn()'s detection of bpf_timer_set_callback() helper by
also checking insn->code == 0. For kfuncs insn->code would be set to
BPF_PSEUDO_KFUNC_CALL, and for subprog calls it will be BPF_PSEUDO_CALL.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20230302235015.2044271-8-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Andrii Nakryiko authored and Alexei Starovoitov committed Mar 4, 2023
1 parent 653ae3a commit c1ee85a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/bpf/verifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -13500,7 +13500,7 @@ static int visit_insn(int t, struct bpf_verifier_env *env)
return DONE_EXPLORING;

case BPF_CALL:
if (insn->imm == BPF_FUNC_timer_set_callback)
if (insn->src_reg == 0 && insn->imm == BPF_FUNC_timer_set_callback)
/* Mark this call insn as a prune point to trigger
* is_state_visited() check before call itself is
* processed by __check_func_call(). Otherwise new
Expand Down

0 comments on commit c1ee85a

Please sign in to comment.