bpf: treewide: Align kfunc signatures to prog point-of-view
authorDaniel Xu <dxu@dxuuu.xyz>
Wed, 12 Jun 2024 15:58:33 +0000 (09:58 -0600)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 12 Jun 2024 18:01:31 +0000 (11:01 -0700)
commitcce4c40b960673f9e020835def310f1e89d3a940
treea468b9c66bcea3e5c796b3f1f7d80cb9fa86ca1b
parentec209ad86324de84ef66990f0e9df0851e45e054
bpf: treewide: Align kfunc signatures to prog point-of-view

Previously, kfunc declarations in bpf_kfuncs.h (and others) used "user
facing" types for kfuncs prototypes while the actual kfunc definitions
used "kernel facing" types. More specifically: bpf_dynptr vs
bpf_dynptr_kern, __sk_buff vs sk_buff, and xdp_md vs xdp_buff.

It wasn't an issue before, as the verifier allows aliased types.
However, since we are now generating kfunc prototypes in vmlinux.h (in
addition to keeping bpf_kfuncs.h around), this conflict creates
compilation errors.

Fix this conflict by using "user facing" types in kfunc definitions.
This results in more casts, but otherwise has no additional runtime
cost.

Note, similar to 5b268d1ebcdc ("bpf: Have bpf_rdonly_cast() take a const
pointer"), we also make kfuncs take const arguments where appropriate in
order to make the kfunc more permissive.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Link: https://lore.kernel.org/r/b58346a63a0e66bc9b7504da751b526b0b189a67.1718207789.git.dxu@dxuuu.xyz
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
fs/verity/measure.c
include/linux/bpf.h
kernel/bpf/crypto.c
kernel/bpf/helpers.c
kernel/bpf/verifier.c
kernel/trace/bpf_trace.c
net/core/filter.c
tools/testing/selftests/bpf/progs/ip_check_defrag.c
tools/testing/selftests/bpf/progs/verifier_netfilter_ctx.c