BPF List
 help / color / mirror / Atom feed
* [PATCH v2 bpf-next 0/7] Do not tag selected functions as fmodret targets
@ 2026-11-26 14:29 Anton Protopopov
  2026-11-26 14:29 ` [PATCH v2 bpf-next 1/7] selftests/bpf: Test the tag of vmlinux with do_epoll_create() Anton Protopopov
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Anton Protopopov @ 2026-11-26 14:29 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Kumar Kartikeya Dwivedi, Jiri Olsa,
	Alan Maguire, John Fastabend, bpf
  Cc: Anton Protopopov

With CONFIG_BPF_FMODRET_SCAN=y the build tags the functions that
return errors, so that an fmod_ret program can attach to them. Among
them are functions which BPF itself relies on: the verifier, the
trampolines, kfuncs and helpers. As was suggested by Alexei in [1],
we shouldn't tag such functions.

Changes split into a few logcal pieces:

  * Patch 1 fixes a selftest which will be otherwise broken by this series.
  * Patch 2 excludes the functions which use BPF types.
  * Patch 3 excludes kfuncs and helpers.
  * Patch 4 adds a static list of functions to exclude,
    which contains 6 functions for now.
  * Patch 5 excludes bpf_*() and __bpf_*() of vmlinux.
  * Patch 6 excludes the code of kernel/bpf/* and of JITs (x86 and arm64).
  * Patch 7 adds a corresponding selftest.

In my arm64 vmlinux build this removes 795 tags, 13629 are left.
Precisely,

  * Patch 2, BPF types:        removes 575 targets
  * Patch 3, kfuncs, helpers:  removes another 130 targets
  * Patch 4, by name:          removes another 1 target
  * Patch 5, by prefix:        removes another 65 targets
  * Patch 6, kernel/bpf, JITs: removes another 24 targets

One implementation note: in patch 6 gen-btf.sh lists the symbols with
${NM}, which reads what ${CC} writes, LTO bitcode included, and gives
them to resolve_btfids with --fmodret_deny.

v1 -> v2:
  * New patch 1 to fix the selftest which have used the bpf_dummy_reg()
    function, which patch 2 untags; use do_epoll_create() and also check that
    the one of vmlinux has a tag (ci-bot)
  * Add copy_to_kernel_nofault() and tracepoint_probe_unregister() (Alexei)
  * Add aarch64_insn_read() and aarch64_insn_write() (bot)
  * Drop the *_locked kfuncs, new patch covers them
  * Exclude bpf_*() and __bpf_*() of vmlinux (Alexei)
  * List the symbols in gen-btf.sh with ${NM} instead of
    the llvm-nm of llvm-config, which can be older than
    the compiler (Alexei, bot)
  * Test functions which only one rule untags

v1: https://lore.kernel.org/bpf/20261125212849.868523-1-a.s.protopopov@gmail.com/

Links:

  [1] https://lore.kernel.org/bpf/DN3P7509U44I.MLLYA1W3M3X9@gmail.com/

Anton Protopopov (7):
  selftests/bpf: Test the tag of vmlinux with do_epoll_create()
  resolve_btfids: Do not tag functions which work on BPF objects
  resolve_btfids: Do not tag kfuncs and helpers
  resolve_btfids: Exclude a set of functions by name
  resolve_btfids: Exclude bpf_*() and __bpf_*() of vmlinux
  resolve_btfids: Exclude the code of kernel/bpf and of the JIT
  selftests/bpf: Test functions which must have no fmod_ret tag

 scripts/gen-btf.sh                            |  10 ++
 tools/bpf/resolve_btfids/fmodret.c            | 138 +++++++++++++++++-
 tools/bpf/resolve_btfids/fmodret.h            |   4 +-
 tools/bpf/resolve_btfids/main.c               |   5 +-
 tools/testing/selftests/bpf/config            |   1 +
 .../bpf/prog_tests/fmodret_untagged.c         |  58 ++++++++
 .../selftests/bpf/progs/fmodret_retval.c      |  17 ++-
 .../bpf/test_kmods/bpf_testmod_retval.c       |   6 +
 8 files changed, 230 insertions(+), 9 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/fmodret_untagged.c

-- 
2.43.0


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

end of thread, other threads:[~2026-11-26 15:14 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 14:29 [PATCH v2 bpf-next 0/7] Do not tag selected functions as fmodret targets Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 1/7] selftests/bpf: Test the tag of vmlinux with do_epoll_create() Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 2/7] resolve_btfids: Do not tag functions which work on BPF objects Anton Protopopov
2026-11-26 14:27   ` sashiko-bot
2026-11-26 14:42     ` Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 3/7] resolve_btfids: Do not tag kfuncs and helpers Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 4/7] resolve_btfids: Exclude a set of functions by name Anton Protopopov
2026-11-26 14:26   ` sashiko-bot
2026-11-26 14:44     ` Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 5/7] resolve_btfids: Exclude bpf_*() and __bpf_*() of vmlinux Anton Protopopov
2026-11-26 15:01   ` bot+bpf-ci
2026-11-26 15:26     ` Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 6/7] resolve_btfids: Exclude the code of kernel/bpf and of the JIT Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 7/7] selftests/bpf: Test functions which must have no fmod_ret tag Anton Protopopov
2026-11-26 14:27   ` sashiko-bot
2026-11-26 14:48     ` Anton Protopopov

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