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("scalars: find linked scalars")
9 __failure
10 __msg("math between fp pointer and 2147483647 is not allowed")
scalars(void)11 __naked void scalars(void)
12 {
13 	asm volatile ("				\
14 	r0 = 0;					\
15 	r1 = 0x80000001 ll;			\
16 	r1 /= 1;				\
17 	r2 = r1;				\
18 	r4 = r1;				\
19 	w2 += 0x7FFFFFFF;			\
20 	w4 += 0;				\
21 	if r2 == 0 goto l1;			\
22 	exit;					\
23 l1:						\
24 	r4 >>= 63;				\
25 	r3 = 1;					\
26 	r3 -= r4;				\
27 	r3 *= 0x7FFFFFFF;			\
28 	r3 += r10;				\
29 	*(u8*)(r3 - 1) = r0;			\
30 	exit;					\
31 "	::: __clobber_all);
32 }
33 
34 char _license[] SEC("license") = "GPL";
35