Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: drv-net: Reload pkt pointer after calling filter_udphdr

Fix a verification failure. filter_udphdr() calls bpf_xdp_pull_data(),
which will invalidate all pkt pointers. Therefore, all ctx->data loaded
before filter_udphdr() cannot be used. Reload it to prevent verification
errors.

The error may not appear on some compiler versions if they decide to
load ctx->data after filter_udphdr() when it is first used.

Fixes: efec2e55bdef ("selftests: drv-net: Pull data before parsing headers")
Signed-off-by: Amery Hung <ameryhung@gmail.com>
Acked-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20250925161452.1290694-1-ameryhung@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Amery Hung and committed by
Jakub Kicinski
11ae737e dd5629a6

+4 -5
+4 -5
tools/testing/selftests/net/lib/xdp_native.bpf.c
··· 420 420 421 421 static int xdp_adjst_tail(struct xdp_md *ctx, __u16 port) 422 422 { 423 - void *data = (void *)(long)ctx->data; 424 423 struct udphdr *udph = NULL; 425 424 __s32 *adjust_offset, *val; 426 425 __u32 key, hdr_len; ··· 431 432 if (!udph) 432 433 return XDP_PASS; 433 434 434 - hdr_len = (void *)udph - data + sizeof(struct udphdr); 435 + hdr_len = (void *)udph - (void *)(long)ctx->data + 436 + sizeof(struct udphdr); 435 437 key = XDP_ADJST_OFFSET; 436 438 adjust_offset = bpf_map_lookup_elem(&map_xdp_setup, &key); 437 439 if (!adjust_offset) ··· 572 572 573 573 static int xdp_head_adjst(struct xdp_md *ctx, __u16 port) 574 574 { 575 - void *data_end = (void *)(long)ctx->data_end; 576 - void *data = (void *)(long)ctx->data; 577 575 struct udphdr *udph_ptr = NULL; 578 576 __u32 key, size, hdr_len; 579 577 __s32 *val; ··· 582 584 if (!udph_ptr) 583 585 return XDP_PASS; 584 586 585 - hdr_len = (void *)udph_ptr - data + sizeof(struct udphdr); 587 + hdr_len = (void *)udph_ptr - (void *)(long)ctx->data + 588 + sizeof(struct udphdr); 586 589 587 590 key = XDP_ADJST_OFFSET; 588 591 val = bpf_map_lookup_elem(&map_xdp_setup, &key);