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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/verifier/jset.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 {
  2         "jset: functional",
  3         .insns = {
  4         BPF_DIRECT_PKT_R2,
  5         BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
  6 
  7         /* reg, bit 63 or bit 0 set, taken */
  8         BPF_LD_IMM64(BPF_REG_8, 0x8000000000000001),
  9         BPF_JMP_REG(BPF_JSET, BPF_REG_7, BPF_REG_8, 1),
 10         BPF_EXIT_INSN(),
 11 
 12         /* reg, bit 62, not taken */
 13         BPF_LD_IMM64(BPF_REG_8, 0x4000000000000000),
 14         BPF_JMP_REG(BPF_JSET, BPF_REG_7, BPF_REG_8, 1),
 15         BPF_JMP_IMM(BPF_JA, 0, 0, 1),
 16         BPF_EXIT_INSN(),
 17 
 18         /* imm, any bit set, taken */
 19         BPF_JMP_IMM(BPF_JSET, BPF_REG_7, -1, 1),
 20         BPF_EXIT_INSN(),
 21 
 22         /* imm, bit 31 set, taken */
 23         BPF_JMP_IMM(BPF_JSET, BPF_REG_7, 0x80000000, 1),
 24         BPF_EXIT_INSN(),
 25 
 26         /* all good - return r0 == 2 */
 27         BPF_MOV64_IMM(BPF_REG_0, 2),
 28         BPF_EXIT_INSN(),
 29         },
 30         .prog_type = BPF_PROG_TYPE_SCHED_CLS,
 31         .result = ACCEPT,
 32         .runs = 7,
 33         .retvals = {
 34                 { .retval = 2,
 35                   .data64 = { (1ULL << 63) | (1U << 31) | (1U << 0), }
 36                 },
 37                 { .retval = 2,
 38                   .data64 = { (1ULL << 63) | (1U << 31), }
 39                 },
 40                 { .retval = 2,
 41                   .data64 = { (1ULL << 31) | (1U << 0), }
 42                 },
 43                 { .retval = 2,
 44                   .data64 = { (__u32)-1, }
 45                 },
 46                 { .retval = 2,
 47                   .data64 = { ~0x4000000000000000ULL, }
 48                 },
 49                 { .retval = 0,
 50                   .data64 = { 0, }
 51                 },
 52                 { .retval = 0,
 53                   .data64 = { ~0ULL, }
 54                 },
 55         },
 56         .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 57 },
 58 {
 59         "jset: sign-extend",
 60         .insns = {
 61         BPF_DIRECT_PKT_R2,
 62         BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
 63 
 64         BPF_JMP_IMM(BPF_JSET, BPF_REG_7, 0x80000000, 1),
 65         BPF_EXIT_INSN(),
 66 
 67         BPF_MOV64_IMM(BPF_REG_0, 2),
 68         BPF_EXIT_INSN(),
 69         },
 70         .prog_type = BPF_PROG_TYPE_SCHED_CLS,
 71         .result = ACCEPT,
 72         .retval = 2,
 73         .data = { 1, 0, 0, 0, 0, 0, 0, 1, },
 74         .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 75 },
 76 {
 77         "jset: known const compare",
 78         .insns = {
 79         BPF_MOV64_IMM(BPF_REG_0, 1),
 80         BPF_JMP_IMM(BPF_JSET, BPF_REG_0, 1, 1),
 81         BPF_LDX_MEM(BPF_B, BPF_REG_8, BPF_REG_9, 0),
 82         BPF_EXIT_INSN(),
 83         },
 84         .prog_type = BPF_PROG_TYPE_SOCKET_FILTER,
 85         .errstr_unpriv = "R9 !read_ok",
 86         .result_unpriv = REJECT,
 87         .retval = 1,
 88         .result = ACCEPT,
 89 },
 90 {
 91         "jset: known const compare bad",
 92         .insns = {
 93         BPF_MOV64_IMM(BPF_REG_0, 0),
 94         BPF_JMP_IMM(BPF_JSET, BPF_REG_0, 1, 1),
 95         BPF_LDX_MEM(BPF_B, BPF_REG_8, BPF_REG_9, 0),
 96         BPF_EXIT_INSN(),
 97         },
 98         .prog_type = BPF_PROG_TYPE_SOCKET_FILTER,
 99         .errstr_unpriv = "!read_ok",
100         .result_unpriv = REJECT,
101         .errstr = "!read_ok",
102         .result = REJECT,
103 },
104 {
105         "jset: unknown const compare taken",
106         .insns = {
107         BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_prandom_u32),
108         BPF_JMP_IMM(BPF_JSET, BPF_REG_0, 1, 1),
109         BPF_JMP_IMM(BPF_JA, 0, 0, 1),
110         BPF_LDX_MEM(BPF_B, BPF_REG_8, BPF_REG_9, 0),
111         BPF_EXIT_INSN(),
112         },
113         .prog_type = BPF_PROG_TYPE_SOCKET_FILTER,
114         .errstr_unpriv = "!read_ok",
115         .result_unpriv = REJECT,
116         .errstr = "!read_ok",
117         .result = REJECT,
118 },
119 {
120         "jset: unknown const compare not taken",
121         .insns = {
122         BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_prandom_u32),
123         BPF_JMP_IMM(BPF_JSET, BPF_REG_0, 1, 1),
124         BPF_LDX_MEM(BPF_B, BPF_REG_8, BPF_REG_9, 0),
125         BPF_EXIT_INSN(),
126         },
127         .prog_type = BPF_PROG_TYPE_SOCKET_FILTER,
128         .errstr_unpriv = "!read_ok",
129         .result_unpriv = REJECT,
130         .errstr = "!read_ok",
131         .result = REJECT,
132 },
133 {
134         "jset: half-known const compare",
135         .insns = {
136         BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_prandom_u32),
137         BPF_ALU64_IMM(BPF_OR, BPF_REG_0, 2),
138         BPF_JMP_IMM(BPF_JSET, BPF_REG_0, 3, 1),
139         BPF_LDX_MEM(BPF_B, BPF_REG_8, BPF_REG_9, 0),
140         BPF_MOV64_IMM(BPF_REG_0, 0),
141         BPF_EXIT_INSN(),
142         },
143         .prog_type = BPF_PROG_TYPE_SOCKET_FILTER,
144         .errstr_unpriv = "R9 !read_ok",
145         .result_unpriv = REJECT,
146         .result = ACCEPT,
147 },
148 {
149         "jset: range",
150         .insns = {
151         BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_prandom_u32),
152         BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
153         BPF_MOV64_IMM(BPF_REG_0, 0),
154         BPF_ALU64_IMM(BPF_AND, BPF_REG_1, 0xff),
155         BPF_JMP_IMM(BPF_JSET, BPF_REG_1, 0xf0, 3),
156         BPF_JMP_IMM(BPF_JLT, BPF_REG_1, 0x10, 1),
157         BPF_LDX_MEM(BPF_B, BPF_REG_8, BPF_REG_9, 0),
158         BPF_EXIT_INSN(),
159         BPF_JMP_IMM(BPF_JSET, BPF_REG_1, 0x10, 1),
160         BPF_EXIT_INSN(),
161         BPF_JMP_IMM(BPF_JGE, BPF_REG_1, 0x10, 1),
162         BPF_LDX_MEM(BPF_B, BPF_REG_8, BPF_REG_9, 0),
163         BPF_EXIT_INSN(),
164         },
165         .prog_type = BPF_PROG_TYPE_SOCKET_FILTER,
166         .errstr_unpriv = "R9 !read_ok",
167         .result_unpriv = REJECT,
168         .result = ACCEPT,
169 },
170 

~ [ 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