mbox series

[bpf-next,v5,00/12] bpf: Support dumping kfunc prototypes from BTF

Message ID cover.1718207789.git.dxu@dxuuu.xyz (mailing list archive)
Headers show
Series bpf: Support dumping kfunc prototypes from BTF | expand

Message

Daniel Xu June 12, 2024, 3:58 p.m. UTC
This patchset enables both detecting as well as dumping compilable
prototypes for kfuncs.

The first commit instructs pahole to DECL_TAG kfuncs when available.
This requires v1.27 which was released on 6/11/24. With it, users will
be able to look at BTF inside vmlinux (or modules) and check if the
kfunc they want is available.

The final commit teaches bpftool how to dump kfunc prototypes. This
is done for developer convenience.

The rest of the commits are fixups to enable selftests to use the
newly dumped kfunc prototypes. With these, selftests will regularly
exercise the newly added codepaths.

Tested with and without the required pahole changes:

  * https://github.com/kernel-patches/bpf/pull/7186
  * https://github.com/kernel-patches/bpf/pull/7187

=== Changelog ===
From v4:
* Change bpf_session_cookie() return type
* Only fixup used fentry test kfunc prototypes
* Extract out projection detection into shared btf_is_projection_of()
* Fix kernel test robot build warnings about doc comments

From v3:
* Teach selftests to use dumped prototypes

From v2:
* Update Makefile.btf with pahole flag
* More error checking
* Output formatting changes
* Drop already-merged commit

From v1:
* Add __weak annotation
* Use btf_dump for kfunc prototypes
* Update kernel bpf_rdonly_cast() signature

Daniel Xu (12):
  kbuild: bpf: Tell pahole to DECL_TAG kfuncs
  bpf: selftests: Fix bpf_iter_task_vma_new() prototype
  bpf: selftests: Fix fentry test kfunc prototypes
  bpf: selftests: Fix bpf_cpumask_first_zero() kfunc prototype
  bpf: selftests: Fix bpf_map_sum_elem_count() kfunc prototype
  bpf: Make bpf_session_cookie() kfunc return long *
  bpf: selftests: Namespace struct_opt callbacks in bpf_dctcp
  bpf: verifier: Relax caller requirements for kfunc projection type
    args
  bpf: treewide: Align kfunc signatures to prog point-of-view
  bpf: selftests: nf: Opt out of using generated kfunc prototypes
  bpf: selftests: xfrm: Opt out of using generated kfunc prototypes
  bpftool: Support dumping kfunc prototypes from BTF

 fs/verity/measure.c                           |  5 +-
 include/linux/bpf.h                           |  8 +--
 include/linux/btf.h                           |  1 +
 kernel/bpf/btf.c                              | 13 ++++-
 kernel/bpf/crypto.c                           | 24 +++++---
 kernel/bpf/helpers.c                          | 39 +++++++++----
 kernel/bpf/verifier.c                         | 12 +++-
 kernel/trace/bpf_trace.c                      | 17 +++---
 net/core/filter.c                             | 32 +++++++----
 scripts/Makefile.btf                          |  2 +-
 tools/bpf/bpftool/btf.c                       | 55 +++++++++++++++++++
 .../testing/selftests/bpf/bpf_experimental.h  |  2 +-
 tools/testing/selftests/bpf/progs/bpf_dctcp.c | 36 ++++++------
 .../selftests/bpf/progs/get_func_ip_test.c    |  7 +--
 .../selftests/bpf/progs/ip_check_defrag.c     | 10 ++--
 .../selftests/bpf/progs/map_percpu_stats.c    |  2 +-
 .../selftests/bpf/progs/nested_trust_common.h |  2 +-
 .../testing/selftests/bpf/progs/test_bpf_nf.c |  1 +
 .../selftests/bpf/progs/test_bpf_nf_fail.c    |  1 +
 .../bpf/progs/verifier_netfilter_ctx.c        |  6 +-
 .../selftests/bpf/progs/xdp_synproxy_kern.c   |  1 +
 tools/testing/selftests/bpf/progs/xfrm_info.c |  1 +
 22 files changed, 193 insertions(+), 84 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org June 12, 2024, 6:10 p.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Wed, 12 Jun 2024 09:58:24 -0600 you wrote:
> This patchset enables both detecting as well as dumping compilable
> prototypes for kfuncs.
> 
> The first commit instructs pahole to DECL_TAG kfuncs when available.
> This requires v1.27 which was released on 6/11/24. With it, users will
> be able to look at BTF inside vmlinux (or modules) and check if the
> kfunc they want is available.
> 
> [...]

Here is the summary with links:
  - [bpf-next,v5,01/12] kbuild: bpf: Tell pahole to DECL_TAG kfuncs
    https://git.kernel.org/bpf/bpf-next/c/ebb79e96f1ea
  - [bpf-next,v5,02/12] bpf: selftests: Fix bpf_iter_task_vma_new() prototype
    https://git.kernel.org/bpf/bpf-next/c/718135f5bd24
  - [bpf-next,v5,03/12] bpf: selftests: Fix fentry test kfunc prototypes
    https://git.kernel.org/bpf/bpf-next/c/dff96e4f5078
  - [bpf-next,v5,04/12] bpf: selftests: Fix bpf_cpumask_first_zero() kfunc prototype
    https://git.kernel.org/bpf/bpf-next/c/89f0b1abac49
  - [bpf-next,v5,05/12] bpf: selftests: Fix bpf_map_sum_elem_count() kfunc prototype
    https://git.kernel.org/bpf/bpf-next/c/ac42f636dc11
  - [bpf-next,v5,06/12] bpf: Make bpf_session_cookie() kfunc return long *
    https://git.kernel.org/bpf/bpf-next/c/2b8dd87332cd
  - [bpf-next,v5,07/12] bpf: selftests: Namespace struct_opt callbacks in bpf_dctcp
    https://git.kernel.org/bpf/bpf-next/c/0ce089cbdc6a
  - [bpf-next,v5,08/12] bpf: verifier: Relax caller requirements for kfunc projection type args
    https://git.kernel.org/bpf/bpf-next/c/ec209ad86324
  - [bpf-next,v5,09/12] bpf: treewide: Align kfunc signatures to prog point-of-view
    https://git.kernel.org/bpf/bpf-next/c/cce4c40b9606
  - [bpf-next,v5,10/12] bpf: selftests: nf: Opt out of using generated kfunc prototypes
    https://git.kernel.org/bpf/bpf-next/c/f709124dd72f
  - [bpf-next,v5,11/12] bpf: selftests: xfrm: Opt out of using generated kfunc prototypes
    https://git.kernel.org/bpf/bpf-next/c/c567cba34585
  - [bpf-next,v5,12/12] bpftool: Support dumping kfunc prototypes from BTF
    https://git.kernel.org/bpf/bpf-next/c/770abbb5a25a

You are awesome, thank you!