2 "raw_stack: no skb_load_bytes",
4 BPF_MOV64_IMM(BPF_REG_2
, 4),
5 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
6 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -8),
7 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
8 BPF_MOV64_IMM(BPF_REG_4
, 8),
9 /* Call to skb_load_bytes() omitted. */
10 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
14 .errstr
= "invalid read from stack off -8+0 size 8",
15 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
18 "raw_stack: skb_load_bytes, negative len",
20 BPF_MOV64_IMM(BPF_REG_2
, 4),
21 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
22 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -8),
23 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
24 BPF_MOV64_IMM(BPF_REG_4
, -8),
25 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
26 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
30 .errstr
= "R4 min value is negative",
31 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
34 "raw_stack: skb_load_bytes, negative len 2",
36 BPF_MOV64_IMM(BPF_REG_2
, 4),
37 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
38 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -8),
39 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
40 BPF_MOV64_IMM(BPF_REG_4
, ~0),
41 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
42 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
46 .errstr
= "R4 min value is negative",
47 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
50 "raw_stack: skb_load_bytes, zero len",
52 BPF_MOV64_IMM(BPF_REG_2
, 4),
53 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
54 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -8),
55 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
56 BPF_MOV64_IMM(BPF_REG_4
, 0),
57 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
58 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
62 .errstr
= "invalid stack type R3",
63 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
66 "raw_stack: skb_load_bytes, no init",
68 BPF_MOV64_IMM(BPF_REG_2
, 4),
69 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
70 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -8),
71 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
72 BPF_MOV64_IMM(BPF_REG_4
, 8),
73 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
74 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
78 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
81 "raw_stack: skb_load_bytes, init",
83 BPF_MOV64_IMM(BPF_REG_2
, 4),
84 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
85 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -8),
86 BPF_ST_MEM(BPF_DW
, BPF_REG_6
, 0, 0xcafe),
87 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
88 BPF_MOV64_IMM(BPF_REG_4
, 8),
89 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
90 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
94 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
97 "raw_stack: skb_load_bytes, spilled regs around bounds",
99 BPF_MOV64_IMM(BPF_REG_2
, 4),
100 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
101 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -16),
102 BPF_STX_MEM(BPF_DW
, BPF_REG_6
, BPF_REG_1
, -8),
103 BPF_STX_MEM(BPF_DW
, BPF_REG_6
, BPF_REG_1
, 8),
104 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
105 BPF_MOV64_IMM(BPF_REG_4
, 8),
106 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
107 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, -8),
108 BPF_LDX_MEM(BPF_DW
, BPF_REG_2
, BPF_REG_6
, 8),
109 BPF_LDX_MEM(BPF_W
, BPF_REG_0
, BPF_REG_0
,
110 offsetof(struct __sk_buff
, mark
)),
111 BPF_LDX_MEM(BPF_W
, BPF_REG_2
, BPF_REG_2
,
112 offsetof(struct __sk_buff
, priority
)),
113 BPF_ALU64_REG(BPF_ADD
, BPF_REG_0
, BPF_REG_2
),
117 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
120 "raw_stack: skb_load_bytes, spilled regs corruption",
122 BPF_MOV64_IMM(BPF_REG_2
, 4),
123 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
124 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -8),
125 BPF_STX_MEM(BPF_DW
, BPF_REG_6
, BPF_REG_1
, 0),
126 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
127 BPF_MOV64_IMM(BPF_REG_4
, 8),
128 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
129 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
130 BPF_LDX_MEM(BPF_W
, BPF_REG_0
, BPF_REG_0
,
131 offsetof(struct __sk_buff
, mark
)),
135 .errstr
= "R0 invalid mem access 'inv'",
136 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
137 .flags
= F_NEEDS_EFFICIENT_UNALIGNED_ACCESS
,
140 "raw_stack: skb_load_bytes, spilled regs corruption 2",
142 BPF_MOV64_IMM(BPF_REG_2
, 4),
143 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
144 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -16),
145 BPF_STX_MEM(BPF_DW
, BPF_REG_6
, BPF_REG_1
, -8),
146 BPF_STX_MEM(BPF_DW
, BPF_REG_6
, BPF_REG_1
, 0),
147 BPF_STX_MEM(BPF_DW
, BPF_REG_6
, BPF_REG_1
, 8),
148 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
149 BPF_MOV64_IMM(BPF_REG_4
, 8),
150 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
151 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, -8),
152 BPF_LDX_MEM(BPF_DW
, BPF_REG_2
, BPF_REG_6
, 8),
153 BPF_LDX_MEM(BPF_DW
, BPF_REG_3
, BPF_REG_6
, 0),
154 BPF_LDX_MEM(BPF_W
, BPF_REG_0
, BPF_REG_0
,
155 offsetof(struct __sk_buff
, mark
)),
156 BPF_LDX_MEM(BPF_W
, BPF_REG_2
, BPF_REG_2
,
157 offsetof(struct __sk_buff
, priority
)),
158 BPF_ALU64_REG(BPF_ADD
, BPF_REG_0
, BPF_REG_2
),
159 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_3
,
160 offsetof(struct __sk_buff
, pkt_type
)),
161 BPF_ALU64_REG(BPF_ADD
, BPF_REG_0
, BPF_REG_3
),
165 .errstr
= "R3 invalid mem access 'inv'",
166 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
167 .flags
= F_NEEDS_EFFICIENT_UNALIGNED_ACCESS
,
170 "raw_stack: skb_load_bytes, spilled regs + data",
172 BPF_MOV64_IMM(BPF_REG_2
, 4),
173 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
174 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -16),
175 BPF_STX_MEM(BPF_DW
, BPF_REG_6
, BPF_REG_1
, -8),
176 BPF_STX_MEM(BPF_DW
, BPF_REG_6
, BPF_REG_1
, 0),
177 BPF_STX_MEM(BPF_DW
, BPF_REG_6
, BPF_REG_1
, 8),
178 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
179 BPF_MOV64_IMM(BPF_REG_4
, 8),
180 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
181 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, -8),
182 BPF_LDX_MEM(BPF_DW
, BPF_REG_2
, BPF_REG_6
, 8),
183 BPF_LDX_MEM(BPF_DW
, BPF_REG_3
, BPF_REG_6
, 0),
184 BPF_LDX_MEM(BPF_W
, BPF_REG_0
, BPF_REG_0
,
185 offsetof(struct __sk_buff
, mark
)),
186 BPF_LDX_MEM(BPF_W
, BPF_REG_2
, BPF_REG_2
,
187 offsetof(struct __sk_buff
, priority
)),
188 BPF_ALU64_REG(BPF_ADD
, BPF_REG_0
, BPF_REG_2
),
189 BPF_ALU64_REG(BPF_ADD
, BPF_REG_0
, BPF_REG_3
),
193 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
196 "raw_stack: skb_load_bytes, invalid access 1",
198 BPF_MOV64_IMM(BPF_REG_2
, 4),
199 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
200 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -513),
201 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
202 BPF_MOV64_IMM(BPF_REG_4
, 8),
203 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
204 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
208 .errstr
= "invalid stack type R3 off=-513 access_size=8",
209 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
212 "raw_stack: skb_load_bytes, invalid access 2",
214 BPF_MOV64_IMM(BPF_REG_2
, 4),
215 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
216 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -1),
217 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
218 BPF_MOV64_IMM(BPF_REG_4
, 8),
219 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
220 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
224 .errstr
= "invalid stack type R3 off=-1 access_size=8",
225 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
228 "raw_stack: skb_load_bytes, invalid access 3",
230 BPF_MOV64_IMM(BPF_REG_2
, 4),
231 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
232 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, 0xffffffff),
233 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
234 BPF_MOV64_IMM(BPF_REG_4
, 0xffffffff),
235 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
236 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
240 .errstr
= "R4 min value is negative",
241 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
244 "raw_stack: skb_load_bytes, invalid access 4",
246 BPF_MOV64_IMM(BPF_REG_2
, 4),
247 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
248 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -1),
249 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
250 BPF_MOV64_IMM(BPF_REG_4
, 0x7fffffff),
251 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
252 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
256 .errstr
= "R4 unbounded memory access, use 'var &= const' or 'if (var < const)'",
257 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
260 "raw_stack: skb_load_bytes, invalid access 5",
262 BPF_MOV64_IMM(BPF_REG_2
, 4),
263 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
264 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -512),
265 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
266 BPF_MOV64_IMM(BPF_REG_4
, 0x7fffffff),
267 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
268 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
272 .errstr
= "R4 unbounded memory access, use 'var &= const' or 'if (var < const)'",
273 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
276 "raw_stack: skb_load_bytes, invalid access 6",
278 BPF_MOV64_IMM(BPF_REG_2
, 4),
279 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
280 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -512),
281 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
282 BPF_MOV64_IMM(BPF_REG_4
, 0),
283 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
284 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
288 .errstr
= "invalid stack type R3 off=-512 access_size=0",
289 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
292 "raw_stack: skb_load_bytes, large access",
294 BPF_MOV64_IMM(BPF_REG_2
, 4),
295 BPF_ALU64_REG(BPF_MOV
, BPF_REG_6
, BPF_REG_10
),
296 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_6
, -512),
297 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_6
),
298 BPF_MOV64_IMM(BPF_REG_4
, 512),
299 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_skb_load_bytes
),
300 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_6
, 0),
304 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,