2 "helper access to map: full range",
4 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
5 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
6 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
7 BPF_LD_MAP_FD(BPF_REG_1
, 0),
8 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
9 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
10 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
11 BPF_MOV64_IMM(BPF_REG_2
, sizeof(struct test_val
)),
12 BPF_MOV64_IMM(BPF_REG_3
, 0),
13 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
16 .fixup_map_hash_48b
= { 3 },
18 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
21 "helper access to map: partial range",
23 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
24 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
25 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
26 BPF_LD_MAP_FD(BPF_REG_1
, 0),
27 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
28 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
29 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
30 BPF_MOV64_IMM(BPF_REG_2
, 8),
31 BPF_MOV64_IMM(BPF_REG_3
, 0),
32 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
35 .fixup_map_hash_48b
= { 3 },
37 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
40 "helper access to map: empty range",
42 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
43 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
44 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
45 BPF_LD_MAP_FD(BPF_REG_1
, 0),
46 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
47 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 3),
48 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
49 BPF_MOV64_IMM(BPF_REG_2
, 0),
50 BPF_EMIT_CALL(BPF_FUNC_trace_printk
),
53 .fixup_map_hash_48b
= { 3 },
54 .errstr
= "invalid access to map value, value_size=48 off=0 size=0",
56 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
59 "helper access to map: out-of-bound range",
61 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
62 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
63 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
64 BPF_LD_MAP_FD(BPF_REG_1
, 0),
65 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
66 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
67 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
68 BPF_MOV64_IMM(BPF_REG_2
, sizeof(struct test_val
) + 8),
69 BPF_MOV64_IMM(BPF_REG_3
, 0),
70 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
73 .fixup_map_hash_48b
= { 3 },
74 .errstr
= "invalid access to map value, value_size=48 off=0 size=56",
76 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
79 "helper access to map: negative range",
81 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
82 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
83 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
84 BPF_LD_MAP_FD(BPF_REG_1
, 0),
85 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
86 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
87 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
88 BPF_MOV64_IMM(BPF_REG_2
, -8),
89 BPF_MOV64_IMM(BPF_REG_3
, 0),
90 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
93 .fixup_map_hash_48b
= { 3 },
94 .errstr
= "R2 min value is negative",
96 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
99 "helper access to adjusted map (via const imm): full range",
101 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
102 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
103 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
104 BPF_LD_MAP_FD(BPF_REG_1
, 0),
105 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
106 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 5),
107 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
108 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, offsetof(struct test_val
, foo
)),
109 BPF_MOV64_IMM(BPF_REG_2
,
110 sizeof(struct test_val
) - offsetof(struct test_val
, foo
)),
111 BPF_MOV64_IMM(BPF_REG_3
, 0),
112 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
115 .fixup_map_hash_48b
= { 3 },
117 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
120 "helper access to adjusted map (via const imm): partial range",
122 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
123 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
124 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
125 BPF_LD_MAP_FD(BPF_REG_1
, 0),
126 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
127 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 5),
128 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
129 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, offsetof(struct test_val
, foo
)),
130 BPF_MOV64_IMM(BPF_REG_2
, 8),
131 BPF_MOV64_IMM(BPF_REG_3
, 0),
132 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
135 .fixup_map_hash_48b
= { 3 },
137 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
140 "helper access to adjusted map (via const imm): empty range",
142 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
143 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
144 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
145 BPF_LD_MAP_FD(BPF_REG_1
, 0),
146 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
147 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
148 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
149 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, offsetof(struct test_val
, foo
)),
150 BPF_MOV64_IMM(BPF_REG_2
, 0),
151 BPF_EMIT_CALL(BPF_FUNC_trace_printk
),
154 .fixup_map_hash_48b
= { 3 },
155 .errstr
= "invalid access to map value, value_size=48 off=4 size=0",
157 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
160 "helper access to adjusted map (via const imm): out-of-bound range",
162 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
163 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
164 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
165 BPF_LD_MAP_FD(BPF_REG_1
, 0),
166 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
167 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 5),
168 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
169 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, offsetof(struct test_val
, foo
)),
170 BPF_MOV64_IMM(BPF_REG_2
,
171 sizeof(struct test_val
) - offsetof(struct test_val
, foo
) + 8),
172 BPF_MOV64_IMM(BPF_REG_3
, 0),
173 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
176 .fixup_map_hash_48b
= { 3 },
177 .errstr
= "invalid access to map value, value_size=48 off=4 size=52",
179 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
182 "helper access to adjusted map (via const imm): negative range (> adjustment)",
184 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
185 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
186 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
187 BPF_LD_MAP_FD(BPF_REG_1
, 0),
188 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
189 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 5),
190 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
191 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, offsetof(struct test_val
, foo
)),
192 BPF_MOV64_IMM(BPF_REG_2
, -8),
193 BPF_MOV64_IMM(BPF_REG_3
, 0),
194 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
197 .fixup_map_hash_48b
= { 3 },
198 .errstr
= "R2 min value is negative",
200 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
203 "helper access to adjusted map (via const imm): negative range (< adjustment)",
205 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
206 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
207 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
208 BPF_LD_MAP_FD(BPF_REG_1
, 0),
209 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
210 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 5),
211 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
212 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, offsetof(struct test_val
, foo
)),
213 BPF_MOV64_IMM(BPF_REG_2
, -1),
214 BPF_MOV64_IMM(BPF_REG_3
, 0),
215 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
218 .fixup_map_hash_48b
= { 3 },
219 .errstr
= "R2 min value is negative",
221 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
224 "helper access to adjusted map (via const reg): full range",
226 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
227 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
228 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
229 BPF_LD_MAP_FD(BPF_REG_1
, 0),
230 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
231 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
232 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
233 BPF_MOV64_IMM(BPF_REG_3
, offsetof(struct test_val
, foo
)),
234 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
235 BPF_MOV64_IMM(BPF_REG_2
,
236 sizeof(struct test_val
) - offsetof(struct test_val
, foo
)),
237 BPF_MOV64_IMM(BPF_REG_3
, 0),
238 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
241 .fixup_map_hash_48b
= { 3 },
243 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
246 "helper access to adjusted map (via const reg): partial range",
248 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
249 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
250 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
251 BPF_LD_MAP_FD(BPF_REG_1
, 0),
252 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
253 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
254 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
255 BPF_MOV64_IMM(BPF_REG_3
, offsetof(struct test_val
, foo
)),
256 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
257 BPF_MOV64_IMM(BPF_REG_2
, 8),
258 BPF_MOV64_IMM(BPF_REG_3
, 0),
259 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
262 .fixup_map_hash_48b
= { 3 },
264 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
267 "helper access to adjusted map (via const reg): empty range",
269 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
270 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
271 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
272 BPF_LD_MAP_FD(BPF_REG_1
, 0),
273 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
274 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 5),
275 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
276 BPF_MOV64_IMM(BPF_REG_3
, 0),
277 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
278 BPF_MOV64_IMM(BPF_REG_2
, 0),
279 BPF_EMIT_CALL(BPF_FUNC_trace_printk
),
282 .fixup_map_hash_48b
= { 3 },
283 .errstr
= "R1 min value is outside of the array range",
285 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
288 "helper access to adjusted map (via const reg): out-of-bound range",
290 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
291 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
292 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
293 BPF_LD_MAP_FD(BPF_REG_1
, 0),
294 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
295 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
296 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
297 BPF_MOV64_IMM(BPF_REG_3
, offsetof(struct test_val
, foo
)),
298 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
299 BPF_MOV64_IMM(BPF_REG_2
,
300 sizeof(struct test_val
) -
301 offsetof(struct test_val
, foo
) + 8),
302 BPF_MOV64_IMM(BPF_REG_3
, 0),
303 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
306 .fixup_map_hash_48b
= { 3 },
307 .errstr
= "invalid access to map value, value_size=48 off=4 size=52",
309 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
312 "helper access to adjusted map (via const reg): negative range (> adjustment)",
314 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
315 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
316 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
317 BPF_LD_MAP_FD(BPF_REG_1
, 0),
318 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
319 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
320 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
321 BPF_MOV64_IMM(BPF_REG_3
, offsetof(struct test_val
, foo
)),
322 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
323 BPF_MOV64_IMM(BPF_REG_2
, -8),
324 BPF_MOV64_IMM(BPF_REG_3
, 0),
325 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
328 .fixup_map_hash_48b
= { 3 },
329 .errstr
= "R2 min value is negative",
331 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
334 "helper access to adjusted map (via const reg): negative range (< adjustment)",
336 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
337 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
338 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
339 BPF_LD_MAP_FD(BPF_REG_1
, 0),
340 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
341 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
342 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
343 BPF_MOV64_IMM(BPF_REG_3
, offsetof(struct test_val
, foo
)),
344 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
345 BPF_MOV64_IMM(BPF_REG_2
, -1),
346 BPF_MOV64_IMM(BPF_REG_3
, 0),
347 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
350 .fixup_map_hash_48b
= { 3 },
351 .errstr
= "R2 min value is negative",
353 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
356 "helper access to adjusted map (via variable): full range",
358 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
359 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
360 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
361 BPF_LD_MAP_FD(BPF_REG_1
, 0),
362 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
363 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 7),
364 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
365 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
366 BPF_JMP_IMM(BPF_JGT
, BPF_REG_3
, offsetof(struct test_val
, foo
), 4),
367 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
368 BPF_MOV64_IMM(BPF_REG_2
,
369 sizeof(struct test_val
) - offsetof(struct test_val
, foo
)),
370 BPF_MOV64_IMM(BPF_REG_3
, 0),
371 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
374 .fixup_map_hash_48b
= { 3 },
376 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
379 "helper access to adjusted map (via variable): partial range",
381 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
382 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
383 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
384 BPF_LD_MAP_FD(BPF_REG_1
, 0),
385 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
386 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 7),
387 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
388 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
389 BPF_JMP_IMM(BPF_JGT
, BPF_REG_3
, offsetof(struct test_val
, foo
), 4),
390 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
391 BPF_MOV64_IMM(BPF_REG_2
, 8),
392 BPF_MOV64_IMM(BPF_REG_3
, 0),
393 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
396 .fixup_map_hash_48b
= { 3 },
398 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
401 "helper access to adjusted map (via variable): empty range",
403 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
404 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
405 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
406 BPF_LD_MAP_FD(BPF_REG_1
, 0),
407 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
408 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
409 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
410 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
411 BPF_JMP_IMM(BPF_JGT
, BPF_REG_3
, offsetof(struct test_val
, foo
), 3),
412 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
413 BPF_MOV64_IMM(BPF_REG_2
, 0),
414 BPF_EMIT_CALL(BPF_FUNC_trace_printk
),
417 .fixup_map_hash_48b
= { 3 },
418 .errstr
= "R1 min value is outside of the array range",
420 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
423 "helper access to adjusted map (via variable): no max check",
425 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
426 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
427 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
428 BPF_LD_MAP_FD(BPF_REG_1
, 0),
429 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
430 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
431 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
432 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
433 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
434 BPF_MOV64_IMM(BPF_REG_2
, 1),
435 BPF_MOV64_IMM(BPF_REG_3
, 0),
436 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
439 .fixup_map_hash_48b
= { 3 },
440 .errstr
= "R1 unbounded memory access",
442 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
445 "helper access to adjusted map (via variable): wrong max check",
447 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
448 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
449 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
450 BPF_LD_MAP_FD(BPF_REG_1
, 0),
451 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
452 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 7),
453 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
454 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
455 BPF_JMP_IMM(BPF_JGT
, BPF_REG_3
, offsetof(struct test_val
, foo
), 4),
456 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
457 BPF_MOV64_IMM(BPF_REG_2
,
458 sizeof(struct test_val
) -
459 offsetof(struct test_val
, foo
) + 1),
460 BPF_MOV64_IMM(BPF_REG_3
, 0),
461 BPF_EMIT_CALL(BPF_FUNC_probe_read
),
464 .fixup_map_hash_48b
= { 3 },
465 .errstr
= "invalid access to map value, value_size=48 off=4 size=45",
467 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
470 "helper access to map: bounds check using <, good access",
472 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
473 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
474 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
475 BPF_LD_MAP_FD(BPF_REG_1
, 0),
476 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
477 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
478 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
479 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
480 BPF_JMP_IMM(BPF_JLT
, BPF_REG_3
, 32, 2),
481 BPF_MOV64_IMM(BPF_REG_0
, 0),
483 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
484 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 0),
485 BPF_MOV64_IMM(BPF_REG_0
, 0),
488 .fixup_map_hash_48b
= { 3 },
490 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
493 "helper access to map: bounds check using <, bad access",
495 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
496 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
497 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
498 BPF_LD_MAP_FD(BPF_REG_1
, 0),
499 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
500 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
501 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
502 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
503 BPF_JMP_IMM(BPF_JLT
, BPF_REG_3
, 32, 4),
504 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
505 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 0),
506 BPF_MOV64_IMM(BPF_REG_0
, 0),
508 BPF_MOV64_IMM(BPF_REG_0
, 0),
511 .fixup_map_hash_48b
= { 3 },
513 .errstr
= "R1 unbounded memory access",
514 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
517 "helper access to map: bounds check using <=, good access",
519 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
520 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
521 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
522 BPF_LD_MAP_FD(BPF_REG_1
, 0),
523 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
524 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
525 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
526 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
527 BPF_JMP_IMM(BPF_JLE
, BPF_REG_3
, 32, 2),
528 BPF_MOV64_IMM(BPF_REG_0
, 0),
530 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
531 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 0),
532 BPF_MOV64_IMM(BPF_REG_0
, 0),
535 .fixup_map_hash_48b
= { 3 },
537 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
540 "helper access to map: bounds check using <=, bad access",
542 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
543 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
544 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
545 BPF_LD_MAP_FD(BPF_REG_1
, 0),
546 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
547 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
548 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
549 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
550 BPF_JMP_IMM(BPF_JLE
, BPF_REG_3
, 32, 4),
551 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
552 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 0),
553 BPF_MOV64_IMM(BPF_REG_0
, 0),
555 BPF_MOV64_IMM(BPF_REG_0
, 0),
558 .fixup_map_hash_48b
= { 3 },
560 .errstr
= "R1 unbounded memory access",
561 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
564 "helper access to map: bounds check using s<, good access",
566 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
567 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
568 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
569 BPF_LD_MAP_FD(BPF_REG_1
, 0),
570 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
571 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
572 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
573 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
574 BPF_JMP_IMM(BPF_JSLT
, BPF_REG_3
, 32, 2),
575 BPF_MOV64_IMM(BPF_REG_0
, 0),
577 BPF_JMP_IMM(BPF_JSLT
, BPF_REG_3
, 0, -3),
578 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
579 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 0),
580 BPF_MOV64_IMM(BPF_REG_0
, 0),
583 .fixup_map_hash_48b
= { 3 },
585 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
588 "helper access to map: bounds check using s<, good access 2",
590 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
591 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
592 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
593 BPF_LD_MAP_FD(BPF_REG_1
, 0),
594 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
595 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
596 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
597 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
598 BPF_JMP_IMM(BPF_JSLT
, BPF_REG_3
, 32, 2),
599 BPF_MOV64_IMM(BPF_REG_0
, 0),
601 BPF_JMP_IMM(BPF_JSLT
, BPF_REG_3
, -3, -3),
602 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
603 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 0),
604 BPF_MOV64_IMM(BPF_REG_0
, 0),
607 .fixup_map_hash_48b
= { 3 },
609 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
612 "helper access to map: bounds check using s<, bad access",
614 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
615 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
616 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
617 BPF_LD_MAP_FD(BPF_REG_1
, 0),
618 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
619 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
620 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
621 BPF_LDX_MEM(BPF_DW
, BPF_REG_3
, BPF_REG_0
, 0),
622 BPF_JMP_IMM(BPF_JSLT
, BPF_REG_3
, 32, 2),
623 BPF_MOV64_IMM(BPF_REG_0
, 0),
625 BPF_JMP_IMM(BPF_JSLT
, BPF_REG_3
, -3, -3),
626 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
627 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 0),
628 BPF_MOV64_IMM(BPF_REG_0
, 0),
631 .fixup_map_hash_48b
= { 3 },
633 .errstr
= "R1 min value is negative",
634 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
637 "helper access to map: bounds check using s<=, good access",
639 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
640 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
641 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
642 BPF_LD_MAP_FD(BPF_REG_1
, 0),
643 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
644 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
645 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
646 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
647 BPF_JMP_IMM(BPF_JSLE
, BPF_REG_3
, 32, 2),
648 BPF_MOV64_IMM(BPF_REG_0
, 0),
650 BPF_JMP_IMM(BPF_JSLE
, BPF_REG_3
, 0, -3),
651 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
652 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 0),
653 BPF_MOV64_IMM(BPF_REG_0
, 0),
656 .fixup_map_hash_48b
= { 3 },
658 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
661 "helper access to map: bounds check using s<=, good access 2",
663 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
664 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
665 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
666 BPF_LD_MAP_FD(BPF_REG_1
, 0),
667 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
668 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
669 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
670 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
671 BPF_JMP_IMM(BPF_JSLE
, BPF_REG_3
, 32, 2),
672 BPF_MOV64_IMM(BPF_REG_0
, 0),
674 BPF_JMP_IMM(BPF_JSLE
, BPF_REG_3
, -3, -3),
675 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
676 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 0),
677 BPF_MOV64_IMM(BPF_REG_0
, 0),
680 .fixup_map_hash_48b
= { 3 },
682 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
685 "helper access to map: bounds check using s<=, bad access",
687 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
688 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
689 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
690 BPF_LD_MAP_FD(BPF_REG_1
, 0),
691 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
692 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
693 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_0
),
694 BPF_LDX_MEM(BPF_DW
, BPF_REG_3
, BPF_REG_0
, 0),
695 BPF_JMP_IMM(BPF_JSLE
, BPF_REG_3
, 32, 2),
696 BPF_MOV64_IMM(BPF_REG_0
, 0),
698 BPF_JMP_IMM(BPF_JSLE
, BPF_REG_3
, -3, -3),
699 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
700 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 0),
701 BPF_MOV64_IMM(BPF_REG_0
, 0),
704 .fixup_map_hash_48b
= { 3 },
706 .errstr
= "R1 min value is negative",
707 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
710 "map lookup helper access to map",
712 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
713 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
714 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
715 BPF_LD_MAP_FD(BPF_REG_1
, 0),
716 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
717 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 4),
718 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_0
),
719 BPF_LD_MAP_FD(BPF_REG_1
, 0),
720 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
723 .fixup_map_hash_16b
= { 3, 8 },
725 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
728 "map update helper access to map",
730 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
731 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
732 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
733 BPF_LD_MAP_FD(BPF_REG_1
, 0),
734 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
735 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
736 BPF_MOV64_IMM(BPF_REG_4
, 0),
737 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_0
),
738 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_0
),
739 BPF_LD_MAP_FD(BPF_REG_1
, 0),
740 BPF_EMIT_CALL(BPF_FUNC_map_update_elem
),
743 .fixup_map_hash_16b
= { 3, 10 },
745 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
748 "map update helper access to map: wrong size",
750 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
751 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
752 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
753 BPF_LD_MAP_FD(BPF_REG_1
, 0),
754 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
755 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
756 BPF_MOV64_IMM(BPF_REG_4
, 0),
757 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_0
),
758 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_0
),
759 BPF_LD_MAP_FD(BPF_REG_1
, 0),
760 BPF_EMIT_CALL(BPF_FUNC_map_update_elem
),
763 .fixup_map_hash_8b
= { 3 },
764 .fixup_map_hash_16b
= { 10 },
766 .errstr
= "invalid access to map value, value_size=8 off=0 size=16",
767 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
770 "map helper access to adjusted map (via const imm)",
772 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
773 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
774 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
775 BPF_LD_MAP_FD(BPF_REG_1
, 0),
776 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
777 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 5),
778 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_0
),
779 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, offsetof(struct other_val
, bar
)),
780 BPF_LD_MAP_FD(BPF_REG_1
, 0),
781 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
784 .fixup_map_hash_16b
= { 3, 9 },
786 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
789 "map helper access to adjusted map (via const imm): out-of-bound 1",
791 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
792 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
793 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
794 BPF_LD_MAP_FD(BPF_REG_1
, 0),
795 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
796 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 5),
797 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_0
),
798 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, sizeof(struct other_val
) - 4),
799 BPF_LD_MAP_FD(BPF_REG_1
, 0),
800 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
803 .fixup_map_hash_16b
= { 3, 9 },
805 .errstr
= "invalid access to map value, value_size=16 off=12 size=8",
806 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
809 "map helper access to adjusted map (via const imm): out-of-bound 2",
811 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
812 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
813 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
814 BPF_LD_MAP_FD(BPF_REG_1
, 0),
815 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
816 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 5),
817 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_0
),
818 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -4),
819 BPF_LD_MAP_FD(BPF_REG_1
, 0),
820 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
823 .fixup_map_hash_16b
= { 3, 9 },
825 .errstr
= "invalid access to map value, value_size=16 off=-4 size=8",
826 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
829 "map helper access to adjusted map (via const reg)",
831 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
832 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
833 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
834 BPF_LD_MAP_FD(BPF_REG_1
, 0),
835 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
836 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
837 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_0
),
838 BPF_MOV64_IMM(BPF_REG_3
, offsetof(struct other_val
, bar
)),
839 BPF_ALU64_REG(BPF_ADD
, BPF_REG_2
, BPF_REG_3
),
840 BPF_LD_MAP_FD(BPF_REG_1
, 0),
841 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
844 .fixup_map_hash_16b
= { 3, 10 },
846 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
849 "map helper access to adjusted map (via const reg): out-of-bound 1",
851 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
852 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
853 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
854 BPF_LD_MAP_FD(BPF_REG_1
, 0),
855 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
856 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
857 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_0
),
858 BPF_MOV64_IMM(BPF_REG_3
, sizeof(struct other_val
) - 4),
859 BPF_ALU64_REG(BPF_ADD
, BPF_REG_2
, BPF_REG_3
),
860 BPF_LD_MAP_FD(BPF_REG_1
, 0),
861 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
864 .fixup_map_hash_16b
= { 3, 10 },
866 .errstr
= "invalid access to map value, value_size=16 off=12 size=8",
867 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
870 "map helper access to adjusted map (via const reg): out-of-bound 2",
872 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
873 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
874 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
875 BPF_LD_MAP_FD(BPF_REG_1
, 0),
876 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
877 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
878 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_0
),
879 BPF_MOV64_IMM(BPF_REG_3
, -4),
880 BPF_ALU64_REG(BPF_ADD
, BPF_REG_2
, BPF_REG_3
),
881 BPF_LD_MAP_FD(BPF_REG_1
, 0),
882 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
885 .fixup_map_hash_16b
= { 3, 10 },
887 .errstr
= "invalid access to map value, value_size=16 off=-4 size=8",
888 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
891 "map helper access to adjusted map (via variable)",
893 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
894 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
895 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
896 BPF_LD_MAP_FD(BPF_REG_1
, 0),
897 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
898 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 7),
899 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_0
),
900 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
901 BPF_JMP_IMM(BPF_JGT
, BPF_REG_3
, offsetof(struct other_val
, bar
), 4),
902 BPF_ALU64_REG(BPF_ADD
, BPF_REG_2
, BPF_REG_3
),
903 BPF_LD_MAP_FD(BPF_REG_1
, 0),
904 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
907 .fixup_map_hash_16b
= { 3, 11 },
909 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
912 "map helper access to adjusted map (via variable): no max check",
914 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
915 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
916 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
917 BPF_LD_MAP_FD(BPF_REG_1
, 0),
918 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
919 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 6),
920 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_0
),
921 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
922 BPF_ALU64_REG(BPF_ADD
, BPF_REG_2
, BPF_REG_3
),
923 BPF_LD_MAP_FD(BPF_REG_1
, 0),
924 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
927 .fixup_map_hash_16b
= { 3, 10 },
929 .errstr
= "R2 unbounded memory access, make sure to bounds check any array access into a map",
930 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,
933 "map helper access to adjusted map (via variable): wrong max check",
935 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
936 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
937 BPF_ST_MEM(BPF_DW
, BPF_REG_2
, 0, 0),
938 BPF_LD_MAP_FD(BPF_REG_1
, 0),
939 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
940 BPF_JMP_IMM(BPF_JEQ
, BPF_REG_0
, 0, 7),
941 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_0
),
942 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_0
, 0),
943 BPF_JMP_IMM(BPF_JGT
, BPF_REG_3
, offsetof(struct other_val
, bar
) + 1, 4),
944 BPF_ALU64_REG(BPF_ADD
, BPF_REG_2
, BPF_REG_3
),
945 BPF_LD_MAP_FD(BPF_REG_1
, 0),
946 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem
),
949 .fixup_map_hash_16b
= { 3, 11 },
951 .errstr
= "invalid access to map value, value_size=16 off=9 size=8",
952 .prog_type
= BPF_PROG_TYPE_TRACEPOINT
,