[PATCH bpf-next v1 0/3] Add support to emit verifier warnings

Kumar Kartikeya Dwivedi
2026-03-29T21:25:36Z

Currently, there are only two ways of communicating information to the user
when a program is verified, success or failure with a verbose verifier log.
Some information is meant to be more discretionary, e.g. warning about use of
kfuncs that are deprecated, and may be removed in future kernel releases.

For this purpose, we can make use of the program's stderr stream. Until the
program is finished loading and actually attached somewhere, it cannot write to
its own stream. This means that there is a point where all collected verifier
warnings can be flushed and displayed to the user.

An example is shown below.

$ ./test_progs -t kfunc_implicit_args/test_kfunc_implicit_arg_legacy_impl -v
...
libbpf: prog 'test_kfunc_implicit_arg_legacy_impl': VERIFIER WARNINGS:
WARNING: kfunc_implicit_args.c:40 calls deprecated kfunc bpf_kfunc_implicit_arg_legacy_impl(), which will be removed.
WARNING: Switch to kfunc bpf_kfunc_implicit_arg_legacy() instead.
WARNING: For older kernels, choose the kfunc using bpf_ksym_exists(bpf_kfunc_implicit_arg_legacy).
...

Once GCC BTF tags are available this can be done by annotating kfuncs with
appropriate tags containing the deprecation message, until then we put it in
the verifier for _impl suffixed kfuncs that have been replaced with
KF_IMPLICIT_ARGS variants.

Kumar Kartikeya Dwivedi (3):
bpf: Extract bpf_get_linfo_file_line
bpf: Emit verifier warnings through prog stderr
libbpf: Wire up verifier warning display logic

include/linux/bpf.h | 11 ++++++++
include/linux/bpf_verifier.h | 3 +-
kernel/bpf/core.c | 32 ++++++++++++++++------
kernel/bpf/log.c | 6 ++--
kernel/bpf/verifier.c | 53 ++++++++++++++++++++++++++++++++++++
tools/lib/bpf/libbpf.c | 23 ++++++++++++++++
6 files changed, 115 insertions(+), 13 deletions(-)

base-commit: b6b5e0ebd429d66ce37ae5af649a74ea1f041d92
--
2.52.0