bpf: selftests: fix missing declaration for bpf_copy_from_user_task_str
Subsystems (3)
PATCH 1/1 bpf: selftests: fix missing declaration for bpf_copy_from_user_task_str
Clang BPF compilation fails in bpf_iter_tasks.c due to an implicit declaration of bpf_copy_from_user_task_str(), which is a BPF kfunc exported by the kernel.
Add an explicit prototype in the test program to make the kfunc visible to the BPF compiler and fix the build error.
No functional change intended.
--- tools/testing/selftests/bpf/progs/bpf_iter_tasks.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/testing/selftests/bpf/progs/bpf_iter_tasks.c +5 -0
@@ -4,6 +4,11 @@#include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h> +extern int bpf_copy_from_user_task_str (void *dst,u32 dst__sz, +const void *unsafe_ptr, +struct task_struct *task, +u64 flags); + char _license[] SEC("license") = "GPL";uint32_t tid =0 ;
Signature · 1 line
2.43.0
Quoted 4 lines · Sun Jian
Clang BPF compilation fails in
bpf_iter_tasks.cdue to an implicit declaration ofbpf_copy_from_user_task_str(), which is a BPF kfunc exported by the kernel.
nope. It's there in vmlinux.h
Fix your build setup instead.
pw-bot: cr
Quoted 29 lines
Add an explicit prototype in the test program to make the kfunc visible to the BPF compiler and fix the build error.
No functional change intended.
Signed-off-by Sun Jian <[email protected]>--- tools/testing/selftests/bpf/progs/bpf_iter_tasks.c | 5 +++++ 1 file changed, 5 insertions(+)tools/testing/selftests/bpf/progs/bpf_iter_tasks.c +5
-1@@ -4,6 +4,11 @@#include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h> +extern int bpf_copy_from_user_task_str (void *dst,u32 dst__sz, +const void *unsafe_ptr, +struct task_struct *task, +u64 flags); + char _license[] SEC("license") = "GPL";uint32_t tid =0 ; --2.43.0