public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v3 0/4] Add support to emit verifier warnings
@ 2026-04-18 17:16 Kumar Kartikeya Dwivedi
  2026-04-18 17:16 ` [PATCH bpf-next v3 1/4] bpf: Add support for verifier warning messages Kumar Kartikeya Dwivedi
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2026-04-18 17:16 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Martin KaFai Lau, Eduard Zingerman, Ihor Solodrai, kkd,
	kernel-team

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.

An example is shown below.

$ ./test_progs -t kfunc_implicit_args/test_kfunc_implicit_arg_legacy_impl -v
...
2: (b7) r3 = 0                        ; R3=0
3: (85) call bpf_kfunc_implicit_arg_legacy_impl#114683
kfunc_implicit_args.c:40 (insn #3) uses deprecated kfunc bpf_kfunc_implicit_arg_legacy_impl(), which will be removed.
Switch to kfunc bpf_kfunc_implicit_arg_legacy() instead.
For older kernels, choose the correct kfunc using bpf_ksym_exists().
4: R0=scalar()
4: (95) exit
...

With verbose logging, the deprecation warnings are printed inline in the
verifier log. When no log level is chosen, the warning is printed in a
block, as follows:

libbpf: prog 'test_kfunc_implicit_arg_legacy_impl': -- BEGIN PROG LOAD WARNINGS --
kfunc_implicit_args.c:40 (insn #3) uses deprecated kfunc bpf_kfunc_implicit_arg_legacy_impl(), which will be removed.
Switch to kfunc bpf_kfunc_implicit_arg_legacy() instead.
For older kernels, choose the correct kfunc using bpf_ksym_exists().
-- END PROG LOAD WARNINGS --

Changelog:
----------
v2 -> v3
v2: https://lore.kernel.org/bpf/20260408021359.3786905-1-memxor@gmail.com

 * Use log_level BPF_LOG_LEVEL_WARN bit to request warning logs.
 * Add a selftest.
 * Drop KF_DEPRECATED.

v1 -> v2
v1: https://lore.kernel.org/bpf/20260329212534.3270005-1-memxor@gmail.com

 * Use BTF tags and kfunc flags for deprecation warnings.
 * Reuse verifier log to deliver log messages. (Alexei)
 * Make the mechanism declarative without kfunc lists in verifier.c.

Kumar Kartikeya Dwivedi (4):
  bpf: Add support for verifier warning messages
  bpf: Introduce __bpf_kfunc_mark_deprecated annotation
  libbpf: Request verifier warnings for object loads
  selftests/bpf: Test verifier warning logging

 Documentation/bpf/kfuncs.rst                  | 40 ++++----
 include/linux/bpf_verifier.h                  | 12 ++-
 include/linux/btf.h                           |  5 +
 include/linux/compiler_types.h                | 14 ++-
 kernel/bpf/helpers.c                          |  8 ++
 kernel/bpf/log.c                              |  2 +-
 kernel/bpf/verifier.c                         | 62 ++++++++++++-
 tools/lib/bpf/features.c                      | 56 +++++++++++
 tools/lib/bpf/libbpf.c                        | 25 +++--
 tools/lib/bpf/libbpf.h                        |  7 +-
 tools/lib/bpf/libbpf_internal.h               |  2 +
 .../bpf/prog_tests/kfunc_implicit_args.c      | 92 +++++++++++++++++++
 .../selftests/bpf/test_kmods/bpf_testmod.c    |  1 +
 13 files changed, 291 insertions(+), 35 deletions(-)


base-commit: eb0d6d97c27c29cd7392c8fd74f46edf7dff7ec2
-- 
2.52.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2026-04-20 18:19 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-18 17:16 [PATCH bpf-next v3 0/4] Add support to emit verifier warnings Kumar Kartikeya Dwivedi
2026-04-18 17:16 ` [PATCH bpf-next v3 1/4] bpf: Add support for verifier warning messages Kumar Kartikeya Dwivedi
2026-04-18 17:42   ` sashiko-bot
2026-04-18 20:33     ` Kumar Kartikeya Dwivedi
2026-04-20 13:37   ` Mykyta Yatsenko
2026-04-20 15:26     ` Kumar Kartikeya Dwivedi
2026-04-18 17:16 ` [PATCH bpf-next v3 2/4] bpf: Introduce __bpf_kfunc_mark_deprecated annotation Kumar Kartikeya Dwivedi
2026-04-18 18:06   ` sashiko-bot
2026-04-18 20:34     ` Kumar Kartikeya Dwivedi
2026-04-20 14:21   ` Mykyta Yatsenko
2026-04-20 15:27     ` Kumar Kartikeya Dwivedi
2026-04-20 18:15   ` David Faust
2026-04-20 18:19     ` Kumar Kartikeya Dwivedi
2026-04-18 17:16 ` [PATCH bpf-next v3 3/4] libbpf: Request verifier warnings for object loads Kumar Kartikeya Dwivedi
2026-04-18 18:35   ` sashiko-bot
2026-04-18 20:38     ` Kumar Kartikeya Dwivedi
2026-04-20 13:57   ` Mykyta Yatsenko
2026-04-20 15:23     ` Kumar Kartikeya Dwivedi
2026-04-20 15:49       ` Alexei Starovoitov
2026-04-18 17:16 ` [PATCH bpf-next v3 4/4] selftests/bpf: Test verifier warning logging Kumar Kartikeya Dwivedi
2026-04-18 18:45   ` sashiko-bot
2026-04-18 20:39     ` Kumar Kartikeya Dwivedi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox