mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
selftests/bpf: Test changing packet data from kfunc
bpf_xdp_pull_data() is the first kfunc that changes packet data. Make sure the verifier clear all packet pointers after calling packet data changing kfunc. Signed-off-by: Amery Hung <ameryhung@gmail.com> Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Link: https://patch.msgid.link/20250926164142.1850176-1-ameryhung@gmail.com
This commit is contained in:
parent
d43029ff7d
commit
991e555eff
|
|
@ -1096,6 +1096,20 @@ int invalidate_xdp_pkt_pointers_from_global_func(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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user