Re: [PATCH bpf-next v3 3/4] libbpf: Request verifier warnings for object loads

Kumar Kartikeya Dwivedi
2026-04-20T15:24:36Z

On Mon, 20 Apr 2026 at 15:57, Mykyta Yatsenko
<mykyta.yatsenko5@gmail.com> wrote:
>
> On 4/18/26 6:16 PM, Kumar Kartikeya Dwivedi wrote:
> > On kernels supporting BPF_LOG_LEVEL_WARN, have libbpf request verifier
> > warnings for BPF object program loads by ORing in the warning bit. This
> > keeps the existing log_level=0 retry semantics for verbose logs, while
> > still surfacing verifier warnings for successful loads.
> >
> > When libbpf owns the log buffer, use a small buffer for warning-only
> > loads and flush captured warnings through the print callback. Detect
> > support by probing for BPF_FEAT_VERIFIER_WARNINGS in enum bpf_features,
> > and document the updated kernel_log_level behavior.
> >
> > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> > ---
> [...]
> > @@ -7954,7 +7960,10 @@ static int bpf_object_load_prog(struct bpf_object *obj, struct bpf_program *prog
> >
> > ret = bpf_prog_load(prog->type, prog_name, license, insns, insns_cnt, &load_attr);
> > if (ret >= 0) {
> > - if (log_level && own_log_buf) {
> > + if (log_level == 16 && load_attr.log_true_size && own_log_buf) {
> > + pr_warn("prog '%s': -- BEGIN PROG LOAD WARNINGS --\n%s-- END PROG LOAD WARNINGS --\n",
> > + prog->name, log_buf);
>
> I'm not sure if this block makes sense to me: we only print warnings
> banner is warnings is the only requested log type, but we print no
> banner if warnings are requested with other log level, also different
> log_levels: pr_warn() vs pr_debug().
>

With other log levels, it becomes part of regular verifier output, if
requested. By default, we want to print them on success at a higher
log level upon success so they appear, even if the user didn't request
verbose logs in the log buffer.
Since the default case only generates warnings, we change the banner,
but keep it as-is for other scenarios. Does that make sense?