Linux Audio

Check our new training course

Linux debugging, profiling, tracing and performance analysis training

Mar 24-27, 2025, special US time zones
Register
Loading...
  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
  7SEC("socket")
  8__description("check deducing bounds from non-const, jmp64, <non_const> == <const>, 1")
  9__success __retval(0)
 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_%=;				\
 17l0_%=:							\
 18	r0 = 0;						\
 19	exit;						\
 20l1_%=:							\
 21	r0 -= r1;					\
 22	exit;						\
 23"	:
 24	: __imm(bpf_ktime_get_ns)
 25	: __clobber_all);
 26}
 27
 28SEC("socket")
 29__description("check deducing bounds from non-const, jmp64, <non_const> == <const>, 2")
 30__success __retval(0)
 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_%=;				\
 38l0_%=:							\
 39	r0 = 0;						\
 40	exit;						\
 41l1_%=:							\
 42	r0 -= r1;					\
 43	exit;						\
 44"	:
 45	: __imm(bpf_ktime_get_ns)
 46	: __clobber_all);
 47}
 48
 49SEC("socket")
 50__description("check deducing bounds from non-const, jmp64, <non_const> != <const>, 1")
 51__success __retval(0)
 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_%=;					\
 60l0_%=:							\
 61	r0 = 0;						\
 62	exit;						\
 63l1_%=:							\
 64	r0 -= r1;					\
 65	exit;						\
 66"	:
 67	: __imm(bpf_ktime_get_ns)
 68	: __clobber_all);
 69}
 70
 71SEC("socket")
 72__description("check deducing bounds from non-const, jmp64, <non_const> != <const>, 2")
 73__success __retval(0)
 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_%=;					\
 82l0_%=:							\
 83	r0 = 0;						\
 84	exit;						\
 85l1_%=:							\
 86	r0 -= r1;					\
 87	exit;						\
 88"	:
 89	: __imm(bpf_ktime_get_ns)
 90	: __clobber_all);
 91}
 92
 93SEC("socket")
 94__description("check deducing bounds from non-const, jmp32, <non_const> == <const>, 1")
 95__success __retval(0)
 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_%=;				\
103l0_%=:							\
104	r0 = 0;						\
105	exit;						\
106l1_%=:							\
107	r0 -= r1;					\
108	exit;						\
109"	:
110	: __imm(bpf_ktime_get_ns)
111	: __clobber_all);
112}
113
114SEC("socket")
115__description("check deducing bounds from non-const, jmp32, <non_const> == <const>, 2")
116__success __retval(0)
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_%=;				\
124l0_%=:							\
125	r0 = 0;						\
126	exit;						\
127l1_%=:							\
128	r0 -= r1;					\
129	exit;						\
130"	:
131	: __imm(bpf_ktime_get_ns)
132	: __clobber_all);
133}
134
135SEC("socket")
136__description("check deducing bounds from non-const, jmp32, <non_const> != <const>, 1")
137__success __retval(0)
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_%=;					\
146l0_%=:							\
147	r0 = 0;						\
148	exit;						\
149l1_%=:							\
150	r0 -= r1;					\
151	exit;						\
152"	:
153	: __imm(bpf_ktime_get_ns)
154	: __clobber_all);
155}
156
157SEC("socket")
158__description("check deducing bounds from non-const, jmp32, <non_const> != <const>, 2")
159__success __retval(0)
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_%=;					\
168l0_%=:							\
169	r0 = 0;						\
170	exit;						\
171l1_%=:							\
172	r0 -= r1;					\
173	exit;						\
174"	:
175	: __imm(bpf_ktime_get_ns)
176	: __clobber_all);
177}
178
179SEC("socket")
180__description("check deducing bounds from non-const, jmp64, <const> > <non_const>, 1")
181__success __retval(0)
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;						\
190l0_%=:							\
191	r0 -= r1;					\
192	exit;						\
193"	:
194	: __imm(bpf_ktime_get_ns)
195	: __clobber_all);
196}
197
198SEC("socket")
199__description("check deducing bounds from non-const, jmp64, <const> > <non_const>, 2")
200__success __retval(0)
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_%=;				\
208l0_%=:							\
209	r0 = 0;						\
210	exit;						\
211l1_%=:							\
212	r0 -= r1;					\
213	exit;						\
214"	:
215	: __imm(bpf_ktime_get_ns)
216	: __clobber_all);
217}
218
219SEC("socket")
220__description("check deducing bounds from non-const, jmp64, <const> >= <non_const>")
221__success __retval(0)
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_%=;				\
229l0_%=:							\
230	r0 = 0;						\
231	exit;						\
232l1_%=:							\
233	r0 -= r1;					\
234	exit;						\
235"	:
236	: __imm(bpf_ktime_get_ns)
237	: __clobber_all);
238}
239
240SEC("socket")
241__description("check deducing bounds from non-const, jmp64, <const> < <non_const>")
242__success __retval(0)
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_%=;				\
250l0_%=:							\
251	r0 = 0;						\
252	exit;						\
253l1_%=:							\
254	r0 -= r1;					\
255	exit;						\
256"	:
257	: __imm(bpf_ktime_get_ns)
258	: __clobber_all);
259}
260
261SEC("socket")
262__description("check deducing bounds from non-const, jmp64, <const> <= <non_const>")
263__success __retval(0)
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_%=;				\
271l0_%=:							\
272	r0 = 0;						\
273	exit;						\
274l1_%=:							\
275	r0 -= r1;					\
276	exit;						\
277"	:
278	: __imm(bpf_ktime_get_ns)
279	: __clobber_all);
280}
281
282SEC("socket")
283__description("check deducing bounds from non-const, jmp64, <const> == <non_const>")
284__success __retval(0)
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_%=;				\
292l0_%=:							\
293	r0 = 0;						\
294	exit;						\
295l1_%=:							\
296	r0 -= r1;					\
297	exit;						\
298"	:
299	: __imm(bpf_ktime_get_ns)
300	: __clobber_all);
301}
302
303SEC("socket")
304__description("check deducing bounds from non-const, jmp64, <const> s> <non_const>")
305__success __retval(0)
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_%=;				\
313l0_%=:							\
314	r0 = 0;						\
315	exit;						\
316l1_%=:							\
317	r0 -= r1;					\
318	exit;						\
319"	:
320	: __imm(bpf_ktime_get_ns)
321	: __clobber_all);
322}
323
324SEC("socket")
325__description("check deducing bounds from non-const, jmp64, <const> s>= <non_const>")
326__success __retval(0)
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_%=;				\
334l0_%=:							\
335	r0 = 0;						\
336	exit;						\
337l1_%=:							\
338	r0 -= r1;					\
339	exit;						\
340"	:
341	: __imm(bpf_ktime_get_ns)
342	: __clobber_all);
343}
344
345SEC("socket")
346__description("check deducing bounds from non-const, jmp64, <const> s< <non_const>")
347__success __retval(0)
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_%=;				\
355l0_%=:							\
356	r0 = 0;						\
357	exit;						\
358l1_%=:							\
359	r0 -= r1;					\
360	exit;						\
361"	:
362	: __imm(bpf_ktime_get_ns)
363	: __clobber_all);
364}
365
366SEC("socket")
367__description("check deducing bounds from non-const, jmp64, <const> s<= <non_const>")
368__success __retval(0)
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_%=;				\
376l0_%=:							\
377	r0 = 0;						\
378	exit;						\
379l1_%=:							\
380	r0 -= r1;					\
381	exit;						\
382"	:
383	: __imm(bpf_ktime_get_ns)
384	: __clobber_all);
385}
386
387SEC("socket")
388__description("check deducing bounds from non-const, jmp64, <const> != <non_const>")
389__success __retval(0)
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_%=;					\
398l0_%=:							\
399	r0 = 0;						\
400	exit;						\
401l1_%=:							\
402	r0 -= r1;					\
403	exit;						\
404"	:
405	: __imm(bpf_ktime_get_ns)
406	: __clobber_all);
407}
408
409SEC("socket")
410__description("check deducing bounds from non-const, jmp32, <const> > <non_const>, 1")
411__success __retval(0)
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;						\
420l0_%=:							\
421	r0 -= r1;					\
422	exit;						\
423"	:
424	: __imm(bpf_ktime_get_ns)
425	: __clobber_all);
426}
427
428SEC("socket")
429__description("check deducing bounds from non-const, jmp32, <const> > <non_const>, 2")
430__success __retval(0)
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_%=;				\
438l0_%=:							\
439	r0 = 0;						\
440	exit;						\
441l1_%=:							\
442	r0 -= r1;					\
443	exit;						\
444"	:
445	: __imm(bpf_ktime_get_ns)
446	: __clobber_all);
447}
448
449SEC("socket")
450__description("check deducing bounds from non-const, jmp32, <const> >= <non_const>")
451__success __retval(0)
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_%=;				\
459l0_%=:							\
460	r0 = 0;						\
461	exit;						\
462l1_%=:							\
463	r0 -= r1;					\
464	exit;						\
465"	:
466	: __imm(bpf_ktime_get_ns)
467	: __clobber_all);
468}
469
470SEC("socket")
471__description("check deducing bounds from non-const, jmp32, <const> < <non_const>")
472__success __retval(0)
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_%=;				\
480l0_%=:							\
481	r0 = 0;						\
482	exit;						\
483l1_%=:							\
484	r0 -= r1;					\
485	exit;						\
486"	:
487	: __imm(bpf_ktime_get_ns)
488	: __clobber_all);
489}
490
491SEC("socket")
492__description("check deducing bounds from non-const, jmp32, <const> <= <non_const>")
493__success __retval(0)
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_%=;				\
501l0_%=:							\
502	r0 = 0;						\
503	exit;						\
504l1_%=:							\
505	r0 -= r1;					\
506	exit;						\
507"	:
508	: __imm(bpf_ktime_get_ns)
509	: __clobber_all);
510}
511
512SEC("socket")
513__description("check deducing bounds from non-const, jmp32, <const> == <non_const>")
514__success __retval(0)
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_%=;				\
522l0_%=:							\
523	r0 = 0;						\
524	exit;						\
525l1_%=:							\
526	r0 -= r1;					\
527	exit;						\
528"	:
529	: __imm(bpf_ktime_get_ns)
530	: __clobber_all);
531}
532
533SEC("socket")
534__description("check deducing bounds from non-const, jmp32, <const> s> <non_const>")
535__success __retval(0)
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_%=;				\
543l0_%=:							\
544	r0 = 0;						\
545	exit;						\
546l1_%=:							\
547	r0 -= r1;					\
548	exit;						\
549"	:
550	: __imm(bpf_ktime_get_ns)
551	: __clobber_all);
552}
553
554SEC("socket")
555__description("check deducing bounds from non-const, jmp32, <const> s>= <non_const>")
556__success __retval(0)
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_%=;				\
564l0_%=:							\
565	r0 = 0;						\
566	exit;						\
567l1_%=:							\
568	r0 -= r1;					\
569	exit;						\
570"	:
571	: __imm(bpf_ktime_get_ns)
572	: __clobber_all);
573}
574
575SEC("socket")
576__description("check deducing bounds from non-const, jmp32, <const> s< <non_const>")
577__success __retval(0)
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_%=;				\
585l0_%=:							\
586	r0 = 0;						\
587	exit;						\
588l1_%=:							\
589	r0 -= r1;					\
590	exit;						\
591"	:
592	: __imm(bpf_ktime_get_ns)
593	: __clobber_all);
594}
595
596SEC("socket")
597__description("check deducing bounds from non-const, jmp32, <const> s<= <non_const>")
598__success __retval(0)
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_%=;				\
606l0_%=:							\
607	r0 = 0;						\
608	exit;						\
609l1_%=:							\
610	r0 -= r1;					\
611	exit;						\
612"	:
613	: __imm(bpf_ktime_get_ns)
614	: __clobber_all);
615}
616
617SEC("socket")
618__description("check deducing bounds from non-const, jmp32, <const> != <non_const>")
619__success __retval(0)
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_%=;					\
628l0_%=:							\
629	r0 = 0;						\
630	exit;						\
631l1_%=:							\
632	r0 -= r1;					\
633	exit;						\
634"	:
635	: __imm(bpf_ktime_get_ns)
636	: __clobber_all);
637}
638
639char _license[] SEC("license") = "GPL";