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

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

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ 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/ld_ind.c */
  3 
  4 #include <linux/bpf.h>
  5 #include <bpf/bpf_helpers.h>
  6 #include "../../../include/linux/filter.h"
  7 #include "bpf_misc.h"
  8 
  9 SEC("socket")
 10 __description("ld_ind: check calling conv, r1")
 11 __failure __msg("R1 !read_ok")
 12 __failure_unpriv
 13 __naked void ind_check_calling_conv_r1(void)
 14 {
 15         asm volatile ("                                 \
 16         r6 = r1;                                        \
 17         r1 = 1;                                         \
 18         .8byte %[ld_ind];                               \
 19         r0 = r1;                                        \
 20         exit;                                           \
 21 "       :
 22         : __imm_insn(ld_ind, BPF_LD_IND(BPF_W, BPF_REG_1, -0x200000))
 23         : __clobber_all);
 24 }
 25 
 26 SEC("socket")
 27 __description("ld_ind: check calling conv, r2")
 28 __failure __msg("R2 !read_ok")
 29 __failure_unpriv
 30 __naked void ind_check_calling_conv_r2(void)
 31 {
 32         asm volatile ("                                 \
 33         r6 = r1;                                        \
 34         r2 = 1;                                         \
 35         .8byte %[ld_ind];                               \
 36         r0 = r2;                                        \
 37         exit;                                           \
 38 "       :
 39         : __imm_insn(ld_ind, BPF_LD_IND(BPF_W, BPF_REG_2, -0x200000))
 40         : __clobber_all);
 41 }
 42 
 43 SEC("socket")
 44 __description("ld_ind: check calling conv, r3")
 45 __failure __msg("R3 !read_ok")
 46 __failure_unpriv
 47 __naked void ind_check_calling_conv_r3(void)
 48 {
 49         asm volatile ("                                 \
 50         r6 = r1;                                        \
 51         r3 = 1;                                         \
 52         .8byte %[ld_ind];                               \
 53         r0 = r3;                                        \
 54         exit;                                           \
 55 "       :
 56         : __imm_insn(ld_ind, BPF_LD_IND(BPF_W, BPF_REG_3, -0x200000))
 57         : __clobber_all);
 58 }
 59 
 60 SEC("socket")
 61 __description("ld_ind: check calling conv, r4")
 62 __failure __msg("R4 !read_ok")
 63 __failure_unpriv
 64 __naked void ind_check_calling_conv_r4(void)
 65 {
 66         asm volatile ("                                 \
 67         r6 = r1;                                        \
 68         r4 = 1;                                         \
 69         .8byte %[ld_ind];                               \
 70         r0 = r4;                                        \
 71         exit;                                           \
 72 "       :
 73         : __imm_insn(ld_ind, BPF_LD_IND(BPF_W, BPF_REG_4, -0x200000))
 74         : __clobber_all);
 75 }
 76 
 77 SEC("socket")
 78 __description("ld_ind: check calling conv, r5")
 79 __failure __msg("R5 !read_ok")
 80 __failure_unpriv
 81 __naked void ind_check_calling_conv_r5(void)
 82 {
 83         asm volatile ("                                 \
 84         r6 = r1;                                        \
 85         r5 = 1;                                         \
 86         .8byte %[ld_ind];                               \
 87         r0 = r5;                                        \
 88         exit;                                           \
 89 "       :
 90         : __imm_insn(ld_ind, BPF_LD_IND(BPF_W, BPF_REG_5, -0x200000))
 91         : __clobber_all);
 92 }
 93 
 94 SEC("socket")
 95 __description("ld_ind: check calling conv, r7")
 96 __success __success_unpriv __retval(1)
 97 __naked void ind_check_calling_conv_r7(void)
 98 {
 99         asm volatile ("                                 \
100         r6 = r1;                                        \
101         r7 = 1;                                         \
102         .8byte %[ld_ind];                               \
103         r0 = r7;                                        \
104         exit;                                           \
105 "       :
106         : __imm_insn(ld_ind, BPF_LD_IND(BPF_W, BPF_REG_7, -0x200000))
107         : __clobber_all);
108 }
109 
110 char _license[] SEC("license") = "GPL";
111 

~ [ 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