mirror of
https://github.com/torvalds/linux.git
synced 2026-05-01 04:52:32 -04:00
This commit adds two new test functions: one to reproduce the bug reported by syzkaller [1], and another to cover the calculation of copied_seq. The tests primarily involve installing and uninstalling sockmap on sockets, then reading data to verify proper functionality. Additionally, extend the do_test_sockmap_skb_verdict_fionread() function to support UDP FIONREAD testing. [1] https://syzkaller.appspot.com/bug?extid=06dbd397158ec0ea4983 Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev> Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com> Link: https://lore.kernel.org/r/20260124113314.113584-4-jiayuan.chen@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
62 lines
1.1 KiB
C
62 lines
1.1 KiB
C
#include <linux/bpf.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
#include <bpf/bpf_endian.h>
|
|
|
|
struct {
|
|
__uint(type, BPF_MAP_TYPE_SOCKMAP);
|
|
__uint(max_entries, 20);
|
|
__type(key, int);
|
|
__type(value, int);
|
|
} sock_map_rx SEC(".maps");
|
|
|
|
struct {
|
|
__uint(type, BPF_MAP_TYPE_SOCKMAP);
|
|
__uint(max_entries, 20);
|
|
__type(key, int);
|
|
__type(value, int);
|
|
} sock_map_tx SEC(".maps");
|
|
|
|
struct {
|
|
__uint(type, BPF_MAP_TYPE_SOCKMAP);
|
|
__uint(max_entries, 20);
|
|
__type(key, int);
|
|
__type(value, int);
|
|
} sock_map_msg SEC(".maps");
|
|
|
|
SEC("sk_skb/stream_verdict")
|
|
int prog_skb_verdict(struct __sk_buff *skb)
|
|
{
|
|
return SK_PASS;
|
|
}
|
|
|
|
int clone_called;
|
|
|
|
SEC("sk_skb/stream_verdict")
|
|
int prog_skb_verdict_clone(struct __sk_buff *skb)
|
|
{
|
|
clone_called = 1;
|
|
return SK_PASS;
|
|
}
|
|
|
|
SEC("sk_skb/stream_parser")
|
|
int prog_skb_parser(struct __sk_buff *skb)
|
|
{
|
|
return SK_PASS;
|
|
}
|
|
|
|
SEC("sk_skb/stream_verdict")
|
|
int prog_skb_verdict_ingress(struct __sk_buff *skb)
|
|
{
|
|
int one = 1;
|
|
|
|
return bpf_sk_redirect_map(skb, &sock_map_rx, one, BPF_F_INGRESS);
|
|
}
|
|
|
|
SEC("sk_skb/stream_parser")
|
|
int prog_skb_verdict_ingress_strp(struct __sk_buff *skb)
|
|
{
|
|
return skb->len;
|
|
}
|
|
|
|
char _license[] SEC("license") = "GPL";
|