1 #define BPF_SOCK_ADDR_STORE(field, off, res, err) \
3 "wide store to bpf_sock_addr." #field "[" #off "]", \
5 BPF_MOV64_IMM(BPF_REG_0, 1), \
6 BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, \
7 offsetof(struct bpf_sock_addr, field[off])), \
11 .prog_type = BPF_PROG_TYPE_CGROUP_SOCK_ADDR, \
12 .expected_attach_type = BPF_CGROUP_UDP6_SENDMSG, \
16 /* user_ip6[0] is u64 aligned */
17 BPF_SOCK_ADDR_STORE(user_ip6
, 0, ACCEPT
,
19 BPF_SOCK_ADDR_STORE(user_ip6
, 1, REJECT
,
20 "invalid bpf_context access off=12 size=8"),
21 BPF_SOCK_ADDR_STORE(user_ip6
, 2, ACCEPT
,
23 BPF_SOCK_ADDR_STORE(user_ip6
, 3, REJECT
,
24 "invalid bpf_context access off=20 size=8"),
26 /* msg_src_ip6[0] is _not_ u64 aligned */
27 BPF_SOCK_ADDR_STORE(msg_src_ip6
, 0, REJECT
,
28 "invalid bpf_context access off=44 size=8"),
29 BPF_SOCK_ADDR_STORE(msg_src_ip6
, 1, ACCEPT
,
31 BPF_SOCK_ADDR_STORE(msg_src_ip6
, 2, REJECT
,
32 "invalid bpf_context access off=52 size=8"),
33 BPF_SOCK_ADDR_STORE(msg_src_ip6
, 3, REJECT
,
34 "invalid bpf_context access off=56 size=8"),
36 #undef BPF_SOCK_ADDR_STORE
38 #define BPF_SOCK_ADDR_LOAD(field, off, res, err) \
40 "wide load from bpf_sock_addr." #field "[" #off "]", \
42 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, \
43 offsetof(struct bpf_sock_addr, field[off])), \
44 BPF_MOV64_IMM(BPF_REG_0, 1), \
48 .prog_type = BPF_PROG_TYPE_CGROUP_SOCK_ADDR, \
49 .expected_attach_type = BPF_CGROUP_UDP6_SENDMSG, \
53 /* user_ip6[0] is u64 aligned */
54 BPF_SOCK_ADDR_LOAD(user_ip6
, 0, ACCEPT
,
56 BPF_SOCK_ADDR_LOAD(user_ip6
, 1, REJECT
,
57 "invalid bpf_context access off=12 size=8"),
58 BPF_SOCK_ADDR_LOAD(user_ip6
, 2, ACCEPT
,
60 BPF_SOCK_ADDR_LOAD(user_ip6
, 3, REJECT
,
61 "invalid bpf_context access off=20 size=8"),
63 /* msg_src_ip6[0] is _not_ u64 aligned */
64 BPF_SOCK_ADDR_LOAD(msg_src_ip6
, 0, REJECT
,
65 "invalid bpf_context access off=44 size=8"),
66 BPF_SOCK_ADDR_LOAD(msg_src_ip6
, 1, ACCEPT
,
68 BPF_SOCK_ADDR_LOAD(msg_src_ip6
, 2, REJECT
,
69 "invalid bpf_context access off=52 size=8"),
70 BPF_SOCK_ADDR_LOAD(msg_src_ip6
, 3, REJECT
,
71 "invalid bpf_context access off=56 size=8"),
73 #undef BPF_SOCK_ADDR_LOAD