Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tools/testing/selftests/bpf/progs/verifier_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,20 @@ int invalidate_xdp_pkt_pointers(struct xdp_md *x)
return XDP_PASS;
}

/* XDP packet changing kfunc calls invalidate packet pointers */
SEC("xdp")
__failure __msg("invalid mem access")
int invalidate_xdp_pkt_pointers(struct xdp_md *x)
{
int *p = (void *)(long)x->data;

if ((void *)(p + 1) > (void *)(long)x->data_end)
return XDP_DROP;
bpf_xdp_pull_data(x, 0);
*p = 42; /* this is unsafe */
return XDP_PASS;
}

__noinline
int tail_call(struct __sk_buff *sk)
{
Expand Down
Loading