Skip to content

Commit 2487007

Browse files
tohojoMartin KaFai Lau
authored andcommitted
cpumap: Zero-initialise xdp_rxq_info struct before running XDP program
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: 9216477 ("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> Link: https://lore.kernel.org/r/20240305213132.11955-1-toke@redhat.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
1 parent 0bfc033 commit 2487007

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/bpf/cpumap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
178178
void **frames, int n,
179179
struct xdp_cpumap_stats *stats)
180180
{
181-
struct xdp_rxq_info rxq;
181+
struct xdp_rxq_info rxq = {};
182182
struct xdp_buff xdp;
183183
int i, nframes = 0;
184184

0 commit comments

Comments
 (0)