Skip to contentSkip to conversation

bpf: selftests: fix missing declaration for bpf_copy_from_user_task_str

PATCH In review Sun Jian 2 participants 2 messages Dec 31, 2025

Subsystems (3)
lore
Share & tools
lore

Sun Jian

author
#0 lore raw

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
index 966ee5a7b066..f5f396b5aa27 100644
@@ -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
#1 lore raw
Quoted 4 lines · Sun Jian

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.

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.

---
 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
index 966ee5a7b066..f5f396b5aa27 100644
@@ -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