* [PATCH bpf] cpumap: Zero-initialise xdp_rxq_info struct before running XDP program
@ 2024-03-05 21:31 Toke Høiland-Jørgensen
2024-03-06 1:10 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Toke Høiland-Jørgensen @ 2024-03-05 21:31 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, David S. Miller,
Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend,
Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Lorenzo Bianconi
Cc: Toke Høiland-Jørgensen, Tobias Böhm, netdev, bpf
When running an XDP program that is attached to a cpumap entry, we don't
initialise the xdp_rxq_info data structure being used in the xdp_buff
that backs the XDP program invocation. Tobias noticed that this leads to
random values being returned as the xdp_md->rx_queue_index value for XDP
programs running in a cpumap.
This means we're basically returning the contents of the uninitialised
memory, which is bad. Fix this by zero-initialising the rxq data
structure before running the XDP program.
Fixes: 9216477449f3 ("bpf: cpumap: Add the possibility to attach an eBPF program to cpumap")
Reported-by: Tobias Böhm <tobias@aibor.de>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
kernel/bpf/cpumap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
index 8a0bb80fe48a..ef82ffc90cbe 100644
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c
@@ -178,7 +178,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
void **frames, int n,
struct xdp_cpumap_stats *stats)
{
- struct xdp_rxq_info rxq;
+ struct xdp_rxq_info rxq = {};
struct xdp_buff xdp;
int i, nframes = 0;
--
2.43.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf] cpumap: Zero-initialise xdp_rxq_info struct before running XDP program
2024-03-05 21:31 [PATCH bpf] cpumap: Zero-initialise xdp_rxq_info struct before running XDP program Toke Høiland-Jørgensen
@ 2024-03-06 1:10 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-06 1:10 UTC (permalink / raw)
To: =?utf-8?b?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2VuIDx0b2tlQHJlZGhhdC5jb20+?=
Cc: ast, daniel, davem, kuba, hawk, john.fastabend, andrii,
martin.lau, song, yonghong.song, kpsingh, sdf, haoluo, jolsa,
lorenzo, tobias, netdev, bpf
Hello:
This patch was applied to bpf/bpf.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:
On Tue, 5 Mar 2024 22:31:32 +0100 you wrote:
> When running an XDP program that is attached to a cpumap entry, we don't
> initialise the xdp_rxq_info data structure being used in the xdp_buff
> that backs the XDP program invocation. Tobias noticed that this leads to
> random values being returned as the xdp_md->rx_queue_index value for XDP
> programs running in a cpumap.
>
> This means we're basically returning the contents of the uninitialised
> memory, which is bad. Fix this by zero-initialising the rxq data
> structure before running the XDP program.
>
> [...]
Here is the summary with links:
- [bpf] cpumap: Zero-initialise xdp_rxq_info struct before running XDP program
https://git.kernel.org/bpf/bpf/c/2487007aa3b9
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:[~2024-03-06 1:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-05 21:31 [PATCH bpf] cpumap: Zero-initialise xdp_rxq_info struct before running XDP program Toke Høiland-Jørgensen
2024-03-06 1:10 ` 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