~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/progs/verifier_const_or.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /* Converted from tools/testing/selftests/bpf/verifier/const_or.c */
  3 
  4 #include <linux/bpf.h>
  5 #include <bpf/bpf_helpers.h>
  6 #include "bpf_misc.h"
  7 
  8 SEC("tracepoint")
  9 __description("constant register |= constant should keep constant type")
 10 __success
 11 __naked void constant_should_keep_constant_type(void)
 12 {
 13         asm volatile ("                                 \
 14         r1 = r10;                                       \
 15         r1 += -48;                                      \
 16         r2 = 34;                                        \
 17         r2 |= 13;                                       \
 18         r3 = 0;                                         \
 19         call %[bpf_probe_read_kernel];                  \
 20         exit;                                           \
 21 "       :
 22         : __imm(bpf_probe_read_kernel)
 23         : __clobber_all);
 24 }
 25 
 26 SEC("tracepoint")
 27 __description("constant register |= constant should not bypass stack boundary checks")
 28 __failure __msg("invalid indirect access to stack R1 off=-48 size=58")
 29 __naked void not_bypass_stack_boundary_checks_1(void)
 30 {
 31         asm volatile ("                                 \
 32         r1 = r10;                                       \
 33         r1 += -48;                                      \
 34         r2 = 34;                                        \
 35         r2 |= 24;                                       \
 36         r3 = 0;                                         \
 37         call %[bpf_probe_read_kernel];                  \
 38         exit;                                           \
 39 "       :
 40         : __imm(bpf_probe_read_kernel)
 41         : __clobber_all);
 42 }
 43 
 44 SEC("tracepoint")
 45 __description("constant register |= constant register should keep constant type")
 46 __success
 47 __naked void register_should_keep_constant_type(void)
 48 {
 49         asm volatile ("                                 \
 50         r1 = r10;                                       \
 51         r1 += -48;                                      \
 52         r2 = 34;                                        \
 53         r4 = 13;                                        \
 54         r2 |= r4;                                       \
 55         r3 = 0;                                         \
 56         call %[bpf_probe_read_kernel];                  \
 57         exit;                                           \
 58 "       :
 59         : __imm(bpf_probe_read_kernel)
 60         : __clobber_all);
 61 }
 62 
 63 SEC("tracepoint")
 64 __description("constant register |= constant register should not bypass stack boundary checks")
 65 __failure __msg("invalid indirect access to stack R1 off=-48 size=58")
 66 __naked void not_bypass_stack_boundary_checks_2(void)
 67 {
 68         asm volatile ("                                 \
 69         r1 = r10;                                       \
 70         r1 += -48;                                      \
 71         r2 = 34;                                        \
 72         r4 = 24;                                        \
 73         r2 |= r4;                                       \
 74         r3 = 0;                                         \
 75         call %[bpf_probe_read_kernel];                  \
 76         exit;                                           \
 77 "       :
 78         : __imm(bpf_probe_read_kernel)
 79         : __clobber_all);
 80 }
 81 
 82 char _license[] SEC("license") = "GPL";
 83 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php