1 // SPDX-License-Identifier: GPL-2.0
2
3 #include <linux/bpf.h>
4 #include <bpf/bpf_helpers.h>
5 #include "bpf_misc.h"
6
7 SEC("socket")
8 __description("check deducing bounds from non-const, jmp64, <non_const> == <const>, 1")
9 __success __retval(0)
deducing_bounds_from_non_const_1(void)10 __naked void deducing_bounds_from_non_const_1(void)
11 {
12 asm volatile (" \
13 call %[bpf_ktime_get_ns]; \
14 if r0 < 3 goto l0_%=; \
15 r2 = 2; \
16 if r0 == r2 goto l1_%=; \
17 l0_%=: \
18 r0 = 0; \
19 exit; \
20 l1_%=: \
21 r0 -= r1; \
22 exit; \
23 " :
24 : __imm(bpf_ktime_get_ns)
25 : __clobber_all);
26 }
27
28 SEC("socket")
29 __description("check deducing bounds from non-const, jmp64, <non_const> == <const>, 2")
30 __success __retval(0)
deducing_bounds_from_non_const_2(void)31 __naked void deducing_bounds_from_non_const_2(void)
32 {
33 asm volatile (" \
34 call %[bpf_ktime_get_ns]; \
35 if r0 > 3 goto l0_%=; \
36 r2 = 4; \
37 if r0 == r2 goto l1_%=; \
38 l0_%=: \
39 r0 = 0; \
40 exit; \
41 l1_%=: \
42 r0 -= r1; \
43 exit; \
44 " :
45 : __imm(bpf_ktime_get_ns)
46 : __clobber_all);
47 }
48
49 SEC("socket")
50 __description("check deducing bounds from non-const, jmp64, <non_const> != <const>, 1")
51 __success __retval(0)
deducing_bounds_from_non_const_3(void)52 __naked void deducing_bounds_from_non_const_3(void)
53 {
54 asm volatile (" \
55 call %[bpf_ktime_get_ns]; \
56 if r0 < 3 goto l0_%=; \
57 r2 = 2; \
58 if r0 != r2 goto l0_%=; \
59 goto l1_%=; \
60 l0_%=: \
61 r0 = 0; \
62 exit; \
63 l1_%=: \
64 r0 -= r1; \
65 exit; \
66 " :
67 : __imm(bpf_ktime_get_ns)
68 : __clobber_all);
69 }
70
71 SEC("socket")
72 __description("check deducing bounds from non-const, jmp64, <non_const> != <const>, 2")
73 __success __retval(0)
deducing_bounds_from_non_const_4(void)74 __naked void deducing_bounds_from_non_const_4(void)
75 {
76 asm volatile (" \
77 call %[bpf_ktime_get_ns]; \
78 if r0 > 3 goto l0_%=; \
79 r2 = 4; \
80 if r0 != r2 goto l0_%=; \
81 goto l1_%=; \
82 l0_%=: \
83 r0 = 0; \
84 exit; \
85 l1_%=: \
86 r0 -= r1; \
87 exit; \
88 " :
89 : __imm(bpf_ktime_get_ns)
90 : __clobber_all);
91 }
92
93 SEC("socket")
94 __description("check deducing bounds from non-const, jmp32, <non_const> == <const>, 1")
95 __success __retval(0)
deducing_bounds_from_non_const_5(void)96 __naked void deducing_bounds_from_non_const_5(void)
97 {
98 asm volatile (" \
99 call %[bpf_ktime_get_ns]; \
100 if w0 < 4 goto l0_%=; \
101 w2 = 3; \
102 if w0 == w2 goto l1_%=; \
103 l0_%=: \
104 r0 = 0; \
105 exit; \
106 l1_%=: \
107 r0 -= r1; \
108 exit; \
109 " :
110 : __imm(bpf_ktime_get_ns)
111 : __clobber_all);
112 }
113
114 SEC("socket")
115 __description("check deducing bounds from non-const, jmp32, <non_const> == <const>, 2")
116 __success __retval(0)
deducing_bounds_from_non_const_6(void)117 __naked void deducing_bounds_from_non_const_6(void)
118 {
119 asm volatile (" \
120 call %[bpf_ktime_get_ns]; \
121 if w0 > 4 goto l0_%=; \
122 w2 = 5; \
123 if w0 == w2 goto l1_%=; \
124 l0_%=: \
125 r0 = 0; \
126 exit; \
127 l1_%=: \
128 r0 -= r1; \
129 exit; \
130 " :
131 : __imm(bpf_ktime_get_ns)
132 : __clobber_all);
133 }
134
135 SEC("socket")
136 __description("check deducing bounds from non-const, jmp32, <non_const> != <const>, 1")
137 __success __retval(0)
deducing_bounds_from_non_const_7(void)138 __naked void deducing_bounds_from_non_const_7(void)
139 {
140 asm volatile (" \
141 call %[bpf_ktime_get_ns]; \
142 if w0 < 3 goto l0_%=; \
143 w2 = 2; \
144 if w0 != w2 goto l0_%=; \
145 goto l1_%=; \
146 l0_%=: \
147 r0 = 0; \
148 exit; \
149 l1_%=: \
150 r0 -= r1; \
151 exit; \
152 " :
153 : __imm(bpf_ktime_get_ns)
154 : __clobber_all);
155 }
156
157 SEC("socket")
158 __description("check deducing bounds from non-const, jmp32, <non_const> != <const>, 2")
159 __success __retval(0)
deducing_bounds_from_non_const_8(void)160 __naked void deducing_bounds_from_non_const_8(void)
161 {
162 asm volatile (" \
163 call %[bpf_ktime_get_ns]; \
164 if w0 > 3 goto l0_%=; \
165 w2 = 4; \
166 if w0 != w2 goto l0_%=; \
167 goto l1_%=; \
168 l0_%=: \
169 r0 = 0; \
170 exit; \
171 l1_%=: \
172 r0 -= r1; \
173 exit; \
174 " :
175 : __imm(bpf_ktime_get_ns)
176 : __clobber_all);
177 }
178
179 SEC("socket")
180 __description("check deducing bounds from non-const, jmp64, <const> > <non_const>, 1")
181 __success __retval(0)
deducing_bounds_from_non_const_9(void)182 __naked void deducing_bounds_from_non_const_9(void)
183 {
184 asm volatile (" \
185 call %[bpf_ktime_get_ns]; \
186 r2 = 0; \
187 if r2 > r0 goto l0_%=; \
188 r0 = 0; \
189 exit; \
190 l0_%=: \
191 r0 -= r1; \
192 exit; \
193 " :
194 : __imm(bpf_ktime_get_ns)
195 : __clobber_all);
196 }
197
198 SEC("socket")
199 __description("check deducing bounds from non-const, jmp64, <const> > <non_const>, 2")
200 __success __retval(0)
deducing_bounds_from_non_const_10(void)201 __naked void deducing_bounds_from_non_const_10(void)
202 {
203 asm volatile (" \
204 call %[bpf_ktime_get_ns]; \
205 if r0 < 4 goto l0_%=; \
206 r2 = 4; \
207 if r2 > r0 goto l1_%=; \
208 l0_%=: \
209 r0 = 0; \
210 exit; \
211 l1_%=: \
212 r0 -= r1; \
213 exit; \
214 " :
215 : __imm(bpf_ktime_get_ns)
216 : __clobber_all);
217 }
218
219 SEC("socket")
220 __description("check deducing bounds from non-const, jmp64, <const> >= <non_const>")
221 __success __retval(0)
deducing_bounds_from_non_const_11(void)222 __naked void deducing_bounds_from_non_const_11(void)
223 {
224 asm volatile (" \
225 call %[bpf_ktime_get_ns]; \
226 if r0 < 4 goto l0_%=; \
227 r2 = 3; \
228 if r2 >= r0 goto l1_%=; \
229 l0_%=: \
230 r0 = 0; \
231 exit; \
232 l1_%=: \
233 r0 -= r1; \
234 exit; \
235 " :
236 : __imm(bpf_ktime_get_ns)
237 : __clobber_all);
238 }
239
240 SEC("socket")
241 __description("check deducing bounds from non-const, jmp64, <const> < <non_const>")
242 __success __retval(0)
deducing_bounds_from_non_const_12(void)243 __naked void deducing_bounds_from_non_const_12(void)
244 {
245 asm volatile (" \
246 call %[bpf_ktime_get_ns]; \
247 if r0 > 4 goto l0_%=; \
248 r2 = 4; \
249 if r2 < r0 goto l1_%=; \
250 l0_%=: \
251 r0 = 0; \
252 exit; \
253 l1_%=: \
254 r0 -= r1; \
255 exit; \
256 " :
257 : __imm(bpf_ktime_get_ns)
258 : __clobber_all);
259 }
260
261 SEC("socket")
262 __description("check deducing bounds from non-const, jmp64, <const> <= <non_const>")
263 __success __retval(0)
deducing_bounds_from_non_const_13(void)264 __naked void deducing_bounds_from_non_const_13(void)
265 {
266 asm volatile (" \
267 call %[bpf_ktime_get_ns]; \
268 if r0 >= 4 goto l0_%=; \
269 r2 = 4; \
270 if r2 <= r0 goto l1_%=; \
271 l0_%=: \
272 r0 = 0; \
273 exit; \
274 l1_%=: \
275 r0 -= r1; \
276 exit; \
277 " :
278 : __imm(bpf_ktime_get_ns)
279 : __clobber_all);
280 }
281
282 SEC("socket")
283 __description("check deducing bounds from non-const, jmp64, <const> == <non_const>")
284 __success __retval(0)
deducing_bounds_from_non_const_14(void)285 __naked void deducing_bounds_from_non_const_14(void)
286 {
287 asm volatile (" \
288 call %[bpf_ktime_get_ns]; \
289 if r0 < 3 goto l0_%=; \
290 r2 = 2; \
291 if r2 == r0 goto l1_%=; \
292 l0_%=: \
293 r0 = 0; \
294 exit; \
295 l1_%=: \
296 r0 -= r1; \
297 exit; \
298 " :
299 : __imm(bpf_ktime_get_ns)
300 : __clobber_all);
301 }
302
303 SEC("socket")
304 __description("check deducing bounds from non-const, jmp64, <const> s> <non_const>")
305 __success __retval(0)
deducing_bounds_from_non_const_15(void)306 __naked void deducing_bounds_from_non_const_15(void)
307 {
308 asm volatile (" \
309 call %[bpf_ktime_get_ns]; \
310 if r0 s< 4 goto l0_%=; \
311 r2 = 4; \
312 if r2 s> r0 goto l1_%=; \
313 l0_%=: \
314 r0 = 0; \
315 exit; \
316 l1_%=: \
317 r0 -= r1; \
318 exit; \
319 " :
320 : __imm(bpf_ktime_get_ns)
321 : __clobber_all);
322 }
323
324 SEC("socket")
325 __description("check deducing bounds from non-const, jmp64, <const> s>= <non_const>")
326 __success __retval(0)
deducing_bounds_from_non_const_16(void)327 __naked void deducing_bounds_from_non_const_16(void)
328 {
329 asm volatile (" \
330 call %[bpf_ktime_get_ns]; \
331 if r0 s< 4 goto l0_%=; \
332 r2 = 3; \
333 if r2 s>= r0 goto l1_%=; \
334 l0_%=: \
335 r0 = 0; \
336 exit; \
337 l1_%=: \
338 r0 -= r1; \
339 exit; \
340 " :
341 : __imm(bpf_ktime_get_ns)
342 : __clobber_all);
343 }
344
345 SEC("socket")
346 __description("check deducing bounds from non-const, jmp64, <const> s< <non_const>")
347 __success __retval(0)
deducing_bounds_from_non_const_17(void)348 __naked void deducing_bounds_from_non_const_17(void)
349 {
350 asm volatile (" \
351 call %[bpf_ktime_get_ns]; \
352 if r0 s> 4 goto l0_%=; \
353 r2 = 4; \
354 if r2 s< r0 goto l1_%=; \
355 l0_%=: \
356 r0 = 0; \
357 exit; \
358 l1_%=: \
359 r0 -= r1; \
360 exit; \
361 " :
362 : __imm(bpf_ktime_get_ns)
363 : __clobber_all);
364 }
365
366 SEC("socket")
367 __description("check deducing bounds from non-const, jmp64, <const> s<= <non_const>")
368 __success __retval(0)
deducing_bounds_from_non_const_18(void)369 __naked void deducing_bounds_from_non_const_18(void)
370 {
371 asm volatile (" \
372 call %[bpf_ktime_get_ns]; \
373 if r0 s> 4 goto l0_%=; \
374 r2 = 5; \
375 if r2 s<= r0 goto l1_%=; \
376 l0_%=: \
377 r0 = 0; \
378 exit; \
379 l1_%=: \
380 r0 -= r1; \
381 exit; \
382 " :
383 : __imm(bpf_ktime_get_ns)
384 : __clobber_all);
385 }
386
387 SEC("socket")
388 __description("check deducing bounds from non-const, jmp64, <const> != <non_const>")
389 __success __retval(0)
deducing_bounds_from_non_const_19(void)390 __naked void deducing_bounds_from_non_const_19(void)
391 {
392 asm volatile (" \
393 call %[bpf_ktime_get_ns]; \
394 if r0 < 3 goto l0_%=; \
395 r2 = 2; \
396 if r2 != r0 goto l0_%=; \
397 goto l1_%=; \
398 l0_%=: \
399 r0 = 0; \
400 exit; \
401 l1_%=: \
402 r0 -= r1; \
403 exit; \
404 " :
405 : __imm(bpf_ktime_get_ns)
406 : __clobber_all);
407 }
408
409 SEC("socket")
410 __description("check deducing bounds from non-const, jmp32, <const> > <non_const>, 1")
411 __success __retval(0)
deducing_bounds_from_non_const_20(void)412 __naked void deducing_bounds_from_non_const_20(void)
413 {
414 asm volatile (" \
415 call %[bpf_ktime_get_ns]; \
416 w2 = 0; \
417 if w2 > w0 goto l0_%=; \
418 r0 = 0; \
419 exit; \
420 l0_%=: \
421 r0 -= r1; \
422 exit; \
423 " :
424 : __imm(bpf_ktime_get_ns)
425 : __clobber_all);
426 }
427
428 SEC("socket")
429 __description("check deducing bounds from non-const, jmp32, <const> > <non_const>, 2")
430 __success __retval(0)
deducing_bounds_from_non_const_21(void)431 __naked void deducing_bounds_from_non_const_21(void)
432 {
433 asm volatile (" \
434 call %[bpf_ktime_get_ns]; \
435 if w0 < 4 goto l0_%=; \
436 w2 = 4; \
437 if w2 > w0 goto l1_%=; \
438 l0_%=: \
439 r0 = 0; \
440 exit; \
441 l1_%=: \
442 r0 -= r1; \
443 exit; \
444 " :
445 : __imm(bpf_ktime_get_ns)
446 : __clobber_all);
447 }
448
449 SEC("socket")
450 __description("check deducing bounds from non-const, jmp32, <const> >= <non_const>")
451 __success __retval(0)
deducing_bounds_from_non_const_22(void)452 __naked void deducing_bounds_from_non_const_22(void)
453 {
454 asm volatile (" \
455 call %[bpf_ktime_get_ns]; \
456 if w0 < 4 goto l0_%=; \
457 w2 = 3; \
458 if w2 >= w0 goto l1_%=; \
459 l0_%=: \
460 r0 = 0; \
461 exit; \
462 l1_%=: \
463 r0 -= r1; \
464 exit; \
465 " :
466 : __imm(bpf_ktime_get_ns)
467 : __clobber_all);
468 }
469
470 SEC("socket")
471 __description("check deducing bounds from non-const, jmp32, <const> < <non_const>")
472 __success __retval(0)
deducing_bounds_from_non_const_23(void)473 __naked void deducing_bounds_from_non_const_23(void)
474 {
475 asm volatile (" \
476 call %[bpf_ktime_get_ns]; \
477 if w0 > 4 goto l0_%=; \
478 w2 = 4; \
479 if w2 < w0 goto l1_%=; \
480 l0_%=: \
481 r0 = 0; \
482 exit; \
483 l1_%=: \
484 r0 -= r1; \
485 exit; \
486 " :
487 : __imm(bpf_ktime_get_ns)
488 : __clobber_all);
489 }
490
491 SEC("socket")
492 __description("check deducing bounds from non-const, jmp32, <const> <= <non_const>")
493 __success __retval(0)
deducing_bounds_from_non_const_24(void)494 __naked void deducing_bounds_from_non_const_24(void)
495 {
496 asm volatile (" \
497 call %[bpf_ktime_get_ns]; \
498 if w0 >= 4 goto l0_%=; \
499 w2 = 4; \
500 if w2 <= w0 goto l1_%=; \
501 l0_%=: \
502 r0 = 0; \
503 exit; \
504 l1_%=: \
505 r0 -= r1; \
506 exit; \
507 " :
508 : __imm(bpf_ktime_get_ns)
509 : __clobber_all);
510 }
511
512 SEC("socket")
513 __description("check deducing bounds from non-const, jmp32, <const> == <non_const>")
514 __success __retval(0)
deducing_bounds_from_non_const_25(void)515 __naked void deducing_bounds_from_non_const_25(void)
516 {
517 asm volatile (" \
518 call %[bpf_ktime_get_ns]; \
519 if w0 < 4 goto l0_%=; \
520 w2 = 3; \
521 if w2 == w0 goto l1_%=; \
522 l0_%=: \
523 r0 = 0; \
524 exit; \
525 l1_%=: \
526 r0 -= r1; \
527 exit; \
528 " :
529 : __imm(bpf_ktime_get_ns)
530 : __clobber_all);
531 }
532
533 SEC("socket")
534 __description("check deducing bounds from non-const, jmp32, <const> s> <non_const>")
535 __success __retval(0)
deducing_bounds_from_non_const_26(void)536 __naked void deducing_bounds_from_non_const_26(void)
537 {
538 asm volatile (" \
539 call %[bpf_ktime_get_ns]; \
540 if w0 s< 4 goto l0_%=; \
541 w2 = 4; \
542 if w2 s> w0 goto l1_%=; \
543 l0_%=: \
544 r0 = 0; \
545 exit; \
546 l1_%=: \
547 r0 -= r1; \
548 exit; \
549 " :
550 : __imm(bpf_ktime_get_ns)
551 : __clobber_all);
552 }
553
554 SEC("socket")
555 __description("check deducing bounds from non-const, jmp32, <const> s>= <non_const>")
556 __success __retval(0)
deducing_bounds_from_non_const_27(void)557 __naked void deducing_bounds_from_non_const_27(void)
558 {
559 asm volatile (" \
560 call %[bpf_ktime_get_ns]; \
561 if w0 s< 4 goto l0_%=; \
562 w2 = 3; \
563 if w2 s>= w0 goto l1_%=; \
564 l0_%=: \
565 r0 = 0; \
566 exit; \
567 l1_%=: \
568 r0 -= r1; \
569 exit; \
570 " :
571 : __imm(bpf_ktime_get_ns)
572 : __clobber_all);
573 }
574
575 SEC("socket")
576 __description("check deducing bounds from non-const, jmp32, <const> s< <non_const>")
577 __success __retval(0)
deducing_bounds_from_non_const_28(void)578 __naked void deducing_bounds_from_non_const_28(void)
579 {
580 asm volatile (" \
581 call %[bpf_ktime_get_ns]; \
582 if w0 s> 4 goto l0_%=; \
583 w2 = 5; \
584 if w2 s< w0 goto l1_%=; \
585 l0_%=: \
586 r0 = 0; \
587 exit; \
588 l1_%=: \
589 r0 -= r1; \
590 exit; \
591 " :
592 : __imm(bpf_ktime_get_ns)
593 : __clobber_all);
594 }
595
596 SEC("socket")
597 __description("check deducing bounds from non-const, jmp32, <const> s<= <non_const>")
598 __success __retval(0)
deducing_bounds_from_non_const_29(void)599 __naked void deducing_bounds_from_non_const_29(void)
600 {
601 asm volatile (" \
602 call %[bpf_ktime_get_ns]; \
603 if w0 s>= 4 goto l0_%=; \
604 w2 = 4; \
605 if w2 s<= w0 goto l1_%=; \
606 l0_%=: \
607 r0 = 0; \
608 exit; \
609 l1_%=: \
610 r0 -= r1; \
611 exit; \
612 " :
613 : __imm(bpf_ktime_get_ns)
614 : __clobber_all);
615 }
616
617 SEC("socket")
618 __description("check deducing bounds from non-const, jmp32, <const> != <non_const>")
619 __success __retval(0)
deducing_bounds_from_non_const_30(void)620 __naked void deducing_bounds_from_non_const_30(void)
621 {
622 asm volatile (" \
623 call %[bpf_ktime_get_ns]; \
624 if w0 < 3 goto l0_%=; \
625 w2 = 2; \
626 if w2 != w0 goto l0_%=; \
627 goto l1_%=; \
628 l0_%=: \
629 r0 = 0; \
630 exit; \
631 l1_%=: \
632 r0 -= r1; \
633 exit; \
634 " :
635 : __imm(bpf_ktime_get_ns)
636 : __clobber_all);
637 }
638
639 char _license[] SEC("license") = "GPL";
640