~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/verifier/wide_access.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #define BPF_SOCK_ADDR_STORE(field, off, res, err, flgs) \
  2 { \
  3         "wide store to bpf_sock_addr." #field "[" #off "]", \
  4         .insns = { \
  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])), \
  8         BPF_EXIT_INSN(), \
  9         }, \
 10         .result = res, \
 11         .prog_type = BPF_PROG_TYPE_CGROUP_SOCK_ADDR, \
 12         .expected_attach_type = BPF_CGROUP_UDP6_SENDMSG, \
 13         .errstr = err, \
 14         .flags = flgs, \
 15 }
 16 
 17 /* user_ip6[0] is u64 aligned */
 18 BPF_SOCK_ADDR_STORE(user_ip6, 0, ACCEPT,
 19                     NULL, 0),
 20 BPF_SOCK_ADDR_STORE(user_ip6, 1, REJECT,
 21                     "invalid bpf_context access off=12 size=8",
 22                     F_NEEDS_EFFICIENT_UNALIGNED_ACCESS),
 23 BPF_SOCK_ADDR_STORE(user_ip6, 2, ACCEPT,
 24                     NULL, 0),
 25 BPF_SOCK_ADDR_STORE(user_ip6, 3, REJECT,
 26                     "invalid bpf_context access off=20 size=8",
 27                     F_NEEDS_EFFICIENT_UNALIGNED_ACCESS),
 28 
 29 /* msg_src_ip6[0] is _not_ u64 aligned */
 30 BPF_SOCK_ADDR_STORE(msg_src_ip6, 0, REJECT,
 31                     "invalid bpf_context access off=44 size=8",
 32                     F_NEEDS_EFFICIENT_UNALIGNED_ACCESS),
 33 BPF_SOCK_ADDR_STORE(msg_src_ip6, 1, ACCEPT,
 34                     NULL, 0),
 35 BPF_SOCK_ADDR_STORE(msg_src_ip6, 2, REJECT,
 36                     "invalid bpf_context access off=52 size=8",
 37                     F_NEEDS_EFFICIENT_UNALIGNED_ACCESS),
 38 BPF_SOCK_ADDR_STORE(msg_src_ip6, 3, REJECT,
 39                     "invalid bpf_context access off=56 size=8", 0),
 40 
 41 #undef BPF_SOCK_ADDR_STORE
 42 
 43 #define BPF_SOCK_ADDR_LOAD(field, off, res, err, flgs)  \
 44 { \
 45         "wide load from bpf_sock_addr." #field "[" #off "]", \
 46         .insns = { \
 47         BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, \
 48                     offsetof(struct bpf_sock_addr, field[off])), \
 49         BPF_MOV64_IMM(BPF_REG_0, 1), \
 50         BPF_EXIT_INSN(), \
 51         }, \
 52         .result = res, \
 53         .prog_type = BPF_PROG_TYPE_CGROUP_SOCK_ADDR, \
 54         .expected_attach_type = BPF_CGROUP_UDP6_SENDMSG, \
 55         .errstr = err, \
 56         .flags = flgs, \
 57 }
 58 
 59 /* user_ip6[0] is u64 aligned */
 60 BPF_SOCK_ADDR_LOAD(user_ip6, 0, ACCEPT,
 61                    NULL, 0),
 62 BPF_SOCK_ADDR_LOAD(user_ip6, 1, REJECT,
 63                    "invalid bpf_context access off=12 size=8",
 64                     F_NEEDS_EFFICIENT_UNALIGNED_ACCESS),
 65 BPF_SOCK_ADDR_LOAD(user_ip6, 2, ACCEPT,
 66                    NULL, 0),
 67 BPF_SOCK_ADDR_LOAD(user_ip6, 3, REJECT,
 68                    "invalid bpf_context access off=20 size=8",
 69                     F_NEEDS_EFFICIENT_UNALIGNED_ACCESS),
 70 
 71 /* msg_src_ip6[0] is _not_ u64 aligned */
 72 BPF_SOCK_ADDR_LOAD(msg_src_ip6, 0, REJECT,
 73                    "invalid bpf_context access off=44 size=8",
 74                     F_NEEDS_EFFICIENT_UNALIGNED_ACCESS),
 75 BPF_SOCK_ADDR_LOAD(msg_src_ip6, 1, ACCEPT,
 76                    NULL, 0),
 77 BPF_SOCK_ADDR_LOAD(msg_src_ip6, 2, REJECT,
 78                    "invalid bpf_context access off=52 size=8",
 79                     F_NEEDS_EFFICIENT_UNALIGNED_ACCESS),
 80 BPF_SOCK_ADDR_LOAD(msg_src_ip6, 3, REJECT,
 81                    "invalid bpf_context access off=56 size=8", 0),
 82 
 83 #undef BPF_SOCK_ADDR_LOAD
 84 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php