Skip to content

Commit e5d2e34

Browse files
eddyz87Alexei Starovoitov
authored andcommitted
bpf: Add missing checks to avoid verbose verifier log
There are a few places where log level is not checked before calling "verbose()". This forces programs working only at BPF_LOG_LEVEL_STATS (e.g. veristat) to allocate unnecessarily large log buffers. Add missing checks. Reported-by: Emil Tsalapatis <[email protected]> Signed-off-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent c1da3df commit e5d2e34

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

kernel/bpf/verifier.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10720,8 +10720,9 @@ static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
1072010720
return err;
1072110721
}
1072210722

10723-
verbose(env, "Func#%d ('%s') is global and assumed valid.\n",
10724-
subprog, sub_name);
10723+
if (env->log.level & BPF_LOG_LEVEL)
10724+
verbose(env, "Func#%d ('%s') is global and assumed valid.\n",
10725+
subprog, sub_name);
1072510726
if (env->subprog_info[subprog].changes_pkt_data)
1072610727
clear_all_pkt_pointers(env);
1072710728
/* mark global subprog for verifying after main prog */
@@ -19470,7 +19471,7 @@ static int propagate_precision(struct bpf_verifier_env *env,
1947019471
bt_set_frame_slot(&env->bt, fr, i);
1947119472
first = false;
1947219473
}
19473-
if (!first)
19474+
if (!first && (env->log.level & BPF_LOG_LEVEL2))
1947419475
verbose(env, "\n");
1947519476
}
1947619477

@@ -23698,7 +23699,8 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog)
2369823699
struct bpf_subprog_arg_info *arg;
2369923700
struct bpf_reg_state *reg;
2370023701

23701-
verbose(env, "Validating %s() func#%d...\n", sub_name, subprog);
23702+
if (env->log.level & BPF_LOG_LEVEL)
23703+
verbose(env, "Validating %s() func#%d...\n", sub_name, subprog);
2370223704
ret = btf_prepare_func_args(env, subprog);
2370323705
if (ret)
2370423706
goto out;

0 commit comments

Comments
 (0)