Commit e5d2e34e authored by Eduard Zingerman's avatar Eduard Zingerman Committed by Alexei Starovoitov
Browse files

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: default avatarEmil Tsalapatis <emil@etsalapatis.com>
Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20251114200542.912386-1-eddyz87@gmail.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent c1da3df7
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -10720,6 +10720,7 @@ static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
			return err;
		}
		if (env->log.level & BPF_LOG_LEVEL)
			verbose(env, "Func#%d ('%s') is global and assumed valid.\n",
				subprog, sub_name);
		if (env->subprog_info[subprog].changes_pkt_data)
@@ -19470,7 +19471,7 @@ static int propagate_precision(struct bpf_verifier_env *env,
			bt_set_frame_slot(&env->bt, fr, i);
			first = false;
		}
		if (!first)
		if (!first && (env->log.level & BPF_LOG_LEVEL2))
			verbose(env, "\n");
	}
@@ -23698,6 +23699,7 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog)
		struct bpf_subprog_arg_info *arg;
		struct bpf_reg_state *reg;
		if (env->log.level & BPF_LOG_LEVEL)
			verbose(env, "Validating %s() func#%d...\n", sub_name, subprog);
		ret = btf_prepare_func_args(env, subprog);
		if (ret)