Skip to content

Commit dcb2288

Browse files
anakryikoborkmann
authored andcommitted
bpf: Remove unused insn_cnt argument from visit_[func_call_]insn()
Number of total instructions in BPF program (including subprogs) can and is accessed from env->prog->len. visit_func_call_insn() doesn't do any checks against insn_cnt anymore, relying on push_insn() to do this check internally. So remove unnecessary insn_cnt input argument from visit_func_call_insn() and visit_insn() functions. Suggested-by: Alexei Starovoitov <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 0a6ea1c commit dcb2288

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

kernel/bpf/verifier.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12222,8 +12222,7 @@ static int push_insn(int t, int w, int e, struct bpf_verifier_env *env,
1222212222
return DONE_EXPLORING;
1222312223
}
1222412224

12225-
static int visit_func_call_insn(int t, int insn_cnt,
12226-
struct bpf_insn *insns,
12225+
static int visit_func_call_insn(int t, struct bpf_insn *insns,
1222712226
struct bpf_verifier_env *env,
1222812227
bool visit_callee)
1222912228
{
@@ -12254,13 +12253,13 @@ static int visit_func_call_insn(int t, int insn_cnt,
1225412253
* DONE_EXPLORING - the instruction was fully explored
1225512254
* KEEP_EXPLORING - there is still work to be done before it is fully explored
1225612255
*/
12257-
static int visit_insn(int t, int insn_cnt, struct bpf_verifier_env *env)
12256+
static int visit_insn(int t, struct bpf_verifier_env *env)
1225812257
{
1225912258
struct bpf_insn *insns = env->prog->insnsi;
1226012259
int ret;
1226112260

1226212261
if (bpf_pseudo_func(insns + t))
12263-
return visit_func_call_insn(t, insn_cnt, insns, env, true);
12262+
return visit_func_call_insn(t, insns, env, true);
1226412263

1226512264
/* All non-branch instructions have a single fall-through edge. */
1226612265
if (BPF_CLASS(insns[t].code) != BPF_JMP &&
@@ -12279,7 +12278,7 @@ static int visit_insn(int t, int insn_cnt, struct bpf_verifier_env *env)
1227912278
* async state will be pushed for further exploration.
1228012279
*/
1228112280
mark_prune_point(env, t);
12282-
return visit_func_call_insn(t, insn_cnt, insns, env,
12281+
return visit_func_call_insn(t, insns, env,
1228312282
insns[t].src_reg == BPF_PSEUDO_CALL);
1228412283

1228512284
case BPF_JA:
@@ -12336,7 +12335,7 @@ static int check_cfg(struct bpf_verifier_env *env)
1233612335
while (env->cfg.cur_stack > 0) {
1233712336
int t = insn_stack[env->cfg.cur_stack - 1];
1233812337

12339-
ret = visit_insn(t, insn_cnt, env);
12338+
ret = visit_insn(t, env);
1234012339
switch (ret) {
1234112340
case DONE_EXPLORING:
1234212341
insn_state[t] = EXPLORED;

0 commit comments

Comments
 (0)