* [PATCH bpf-next] bpf: Emit struct bpf_tcp_sock type in vmlinux BTF
@ 2023-05-02 18:05 Yonghong Song
2023-05-02 23:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Song @ 2023-05-02 18:05 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team,
Martin KaFai Lau
In one of our internal testing, we found a case where
- uapi struct bpf_tcp_sock is in vmlinux.h where vmlinux.h is not
generated from the testing kernel
- struct bpf_tcp_sock is not in vmlinux BTF
The above combination caused bpf load failure as the following
memory access
struct bpf_tcp_sock *tcp_sock = ...;
... tcp_sock->snd_cwnd ...
needs CORE relocation but the relocation cannot be resolved since
the kernel BTF does not have corresponding type.
Similar to other previous cases (nf_conn___init, tcp6_sock, mctcp_sock, etc.),
add the type to vmlinux BTF with BTF_EMIT_TYPE macro.
Signed-off-by: Yonghong Song <yhs@fb.com>
---
net/core/filter.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/core/filter.c b/net/core/filter.c
index d9ce04ca22ce..451b0ec7f242 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -6916,6 +6916,8 @@ u32 bpf_tcp_sock_convert_ctx_access(enum bpf_access_type type,
FIELD)); \
} while (0)
+ BTF_TYPE_EMIT(struct bpf_tcp_sock);
+
switch (si->off) {
case offsetof(struct bpf_tcp_sock, rtt_min):
BUILD_BUG_ON(sizeof_field(struct tcp_sock, rtt_min) !=
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next] bpf: Emit struct bpf_tcp_sock type in vmlinux BTF
2023-05-02 18:05 [PATCH bpf-next] bpf: Emit struct bpf_tcp_sock type in vmlinux BTF Yonghong Song
@ 2023-05-02 23:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-02 23:20 UTC (permalink / raw)
To: Yonghong Song; +Cc: bpf, ast, andrii, daniel, kernel-team, martin.lau
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Tue, 2 May 2023 11:05:43 -0700 you wrote:
> In one of our internal testing, we found a case where
> - uapi struct bpf_tcp_sock is in vmlinux.h where vmlinux.h is not
> generated from the testing kernel
> - struct bpf_tcp_sock is not in vmlinux BTF
>
> The above combination caused bpf load failure as the following
> memory access
> struct bpf_tcp_sock *tcp_sock = ...;
> ... tcp_sock->snd_cwnd ...
> needs CORE relocation but the relocation cannot be resolved since
> the kernel BTF does not have corresponding type.
>
> [...]
Here is the summary with links:
- [bpf-next] bpf: Emit struct bpf_tcp_sock type in vmlinux BTF
https://git.kernel.org/bpf/bpf-next/c/bf6882aebd0e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-02 23:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-02 18:05 [PATCH bpf-next] bpf: Emit struct bpf_tcp_sock type in vmlinux BTF Yonghong Song
2023-05-02 23:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox