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("or_jmp32_k: bit ops + branch on unknown value") 9 __failure 10 __msg("R0 invalid mem access 'scalar'") or_jmp32_k(void)11__naked void or_jmp32_k(void) 12 { 13 asm volatile (" \ 14 r0 = 0xffffffff; \ 15 r0 /= 1; \ 16 r1 = 0; \ 17 w1 = -1; \ 18 w1 >>= 1; \ 19 w0 &= w1; \ 20 w0 |= 2; \ 21 if w0 != 0x7ffffffd goto l1; \ 22 r0 = 1; \ 23 exit; \ 24 l3: \ 25 r0 = 5; \ 26 *(u64*)(r0 - 8) = r0; \ 27 exit; \ 28 l2: \ 29 w0 -= 0xe; \ 30 if w0 == 1 goto l3; \ 31 r0 = 4; \ 32 exit; \ 33 l1: \ 34 w0 -= 0x7ffffff0; \ 35 if w0 s>= 0xe goto l2; \ 36 r0 = 3; \ 37 exit; \ 38 " ::: __clobber_all); 39 } 40 41 char _license[] SEC("license") = "GPL"; 42