]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Add missing checks to avoid verbose verifier log
authorEduard Zingerman <eddyz87@gmail.com>
Fri, 14 Nov 2025 20:05:42 +0000 (12:05 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 14 Nov 2025 21:29:12 +0000 (13:29 -0800)
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 <emil@etsalapatis.com>
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20251114200542.912386-1-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c

index 1268fa075d4c2e4e0e17dba1d329d05fc6e11394..99d62d765b2411279417e234e7a7a43efca1e898 100644 (file)
@@ -10720,8 +10720,9 @@ static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
                        return err;
                }
 
-               verbose(env, "Func#%d ('%s') is global and assumed valid.\n",
-                       subprog, sub_name);
+               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)
                        clear_all_pkt_pointers(env);
                /* mark global subprog for verifying after main prog */
@@ -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,7 +23699,8 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog)
                struct bpf_subprog_arg_info *arg;
                struct bpf_reg_state *reg;
 
-               verbose(env, "Validating %s() func#%d...\n", sub_name, subprog);
+               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)
                        goto out;