[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230517125617.931437-2-arnd@kernel.org>
Date: Wed, 17 May 2023 14:56:09 +0200
From: Arnd Bergmann <arnd@...nel.org>
To: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>,
John Fastabend <john.fastabend@...il.com>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>,
Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
"Jason A. Donenfeld" <Jason@...c4.com>,
Kumar Kartikeya Dwivedi <memxor@...il.com>,
Delyan Kratunov <delyank@...com>,
Ilya Leoshkevich <iii@...ux.ibm.com>,
Menglong Dong <imagedong@...cent.com>,
Yafang Shao <laoar.shao@...il.com>, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] bpf: add bpf_probe_read_kernel declaration
From: Arnd Bergmann <arnd@...db.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@...db.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
Powered by blists - more mailing lists