Messages in this thread Patch in this message | | | From | Arnd Bergmann <> | Subject | [PATCH 2/2] bpf: add bpf_probe_read_kernel declaration | Date | Wed, 17 May 2023 14:56:09 +0200 |
| |
From: Arnd Bergmann <arnd@arndb.de>
bpf_probe_read_kernel() has a __weak definition in core.c and another definition with an incompatible prototype in kernel/trace/bpf_trace.c, when CONFIG_BPF_EVENTS is enabled.
Since the two are incompatible, there cannot be a shared declaration in a header file, but the lack of a prototype causes a W=1 warning:
kernel/bpf/core.c:1638:12: error: no previous prototype for 'bpf_probe_read_kernel' [-Werror=missing-prototypes]
Add a prototype directly in front of the function instead to shut up the warning. Also, to avoid having an incompatible function override the __weak definition, use an #ifdef to ensure that only one of the two is ever defined.
I'm not sure what can be done to make the two prototypes match.
Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- kernel/bpf/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 6f5ede31e471..38762a784b86 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -1635,11 +1635,14 @@ bool bpf_opcode_in_insntable(u8 code) } #ifndef CONFIG_BPF_JIT_ALWAYS_ON -u64 __weak bpf_probe_read_kernel(void *dst, u32 size, const void *unsafe_ptr) +u64 bpf_probe_read_kernel(void *dst, u32 size, const void *unsafe_ptr); +#ifndef CONFIG_BPF_EVENTS +u64 bpf_probe_read_kernel(void *dst, u32 size, const void *unsafe_ptr) { memset(dst, 0, size); return -EFAULT; } +#endif /** * ___bpf_prog_run - run eBPF program on a given context -- 2.39.2
| |