mirror of
https://github.com/torvalds/linux.git
synced 2026-09-26 10:02:02 +02:00
selftests/bpf: Add selftests for rx_queue_mapping context access
Add tests to ensure the verifier properly tracks the 0 bit state and width of the rx_queue_mapping field read from struct sock. Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20260922172028.6269-5-emil@etsalapatis.com
This commit is contained in:
parent
4a4852376e
commit
dec0c209a6
|
|
@ -88,6 +88,44 @@ l0_%=: r0 = *(u32*)(r1 + %[bpf_sock_family]); \
|
|||
: __clobber_all);
|
||||
}
|
||||
|
||||
SEC("socket")
|
||||
__description("skb->sk: sk->rx_queue_mapping [no sign extension]")
|
||||
__success __success_unpriv __retval(0)
|
||||
__naked void sk_rx_queue_mapping_no_sign_ext(void)
|
||||
{
|
||||
asm volatile (" \
|
||||
r1 = *(u64*)(r1 + %[__sk_buff_sk]); \
|
||||
if r1 != 0 goto l0_%=; \
|
||||
r0 = 0xdead; \
|
||||
exit; \
|
||||
l0_%=: r0 = *(u32*)(r1 + %[bpf_sock_rx_queue_mapping]); \
|
||||
r0 >>= 32; \
|
||||
exit; \
|
||||
" :
|
||||
: __imm_const(__sk_buff_sk, offsetof(struct __sk_buff, sk)),
|
||||
__imm_const(bpf_sock_rx_queue_mapping, offsetof(struct bpf_sock, rx_queue_mapping))
|
||||
: __clobber_all);
|
||||
}
|
||||
|
||||
SEC("socket")
|
||||
__description("skb->sk: sk->rx_queue_mapping [narrow load mask]")
|
||||
__success __success_unpriv __retval(0)
|
||||
__naked void sk_rx_queue_mapping_narrow_load_mask(void)
|
||||
{
|
||||
asm volatile (" \
|
||||
r1 = *(u64*)(r1 + %[__sk_buff_sk]); \
|
||||
if r1 != 0 goto l0_%=; \
|
||||
r0 = 0xdead; \
|
||||
exit; \
|
||||
l0_%=: r0 = *(u16*)(r1 + %[bpf_sock_rx_queue_mapping]); \
|
||||
r0 >>= 16; \
|
||||
exit; \
|
||||
" :
|
||||
: __imm_const(__sk_buff_sk, offsetof(struct __sk_buff, sk)),
|
||||
__imm_const(bpf_sock_rx_queue_mapping, offsetof(struct bpf_sock, rx_queue_mapping))
|
||||
: __clobber_all);
|
||||
}
|
||||
|
||||
SEC("cgroup/skb")
|
||||
__description("skb->sk: sk->type [fullsock field]")
|
||||
__failure __msg("invalid sock_common access")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user