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

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

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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 /* Copyright (C) 2023 SUSE LLC */
  3 #include <linux/bpf.h>
  4 #include <bpf/bpf_helpers.h>
  5 #include "bpf_misc.h"
  6 
  7 SEC("?raw_tp")
  8 __success __log_level(2)
  9 __msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r1 = r10")
 10 __msg("mark_precise: frame0: regs=r2 stack= before 2: (55) if r2 != 0xfffffff8 goto pc+2")
 11 __msg("mark_precise: frame0: regs=r2 stack= before 1: (87) r2 = -r2")
 12 __msg("mark_precise: frame0: regs=r2 stack= before 0: (b7) r2 = 8")
 13 __naked int bpf_neg(void)
 14 {
 15         asm volatile (
 16                 "r2 = 8;"
 17                 "r2 = -r2;"
 18                 "if r2 != -8 goto 1f;"
 19                 "r1 = r10;"
 20                 "r1 += r2;"
 21         "1:"
 22                 "r0 = 0;"
 23                 "exit;"
 24                 ::: __clobber_all);
 25 }
 26 
 27 SEC("?raw_tp")
 28 __success __log_level(2)
 29 __msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r1 = r10")
 30 __msg("mark_precise: frame0: regs=r2 stack= before 2: (55) if r2 != 0x0 goto pc+2")
 31 __msg("mark_precise: frame0: regs=r2 stack= before 1: (d4) r2 = le16 r2")
 32 __msg("mark_precise: frame0: regs=r2 stack= before 0: (b7) r2 = 0")
 33 __naked int bpf_end_to_le(void)
 34 {
 35         asm volatile (
 36                 "r2 = 0;"
 37                 "r2 = le16 r2;"
 38                 "if r2 != 0 goto 1f;"
 39                 "r1 = r10;"
 40                 "r1 += r2;"
 41         "1:"
 42                 "r0 = 0;"
 43                 "exit;"
 44                 ::: __clobber_all);
 45 }
 46 
 47 
 48 SEC("?raw_tp")
 49 __success __log_level(2)
 50 __msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r1 = r10")
 51 __msg("mark_precise: frame0: regs=r2 stack= before 2: (55) if r2 != 0x0 goto pc+2")
 52 __msg("mark_precise: frame0: regs=r2 stack= before 1: (dc) r2 = be16 r2")
 53 __msg("mark_precise: frame0: regs=r2 stack= before 0: (b7) r2 = 0")
 54 __naked int bpf_end_to_be(void)
 55 {
 56         asm volatile (
 57                 "r2 = 0;"
 58                 "r2 = be16 r2;"
 59                 "if r2 != 0 goto 1f;"
 60                 "r1 = r10;"
 61                 "r1 += r2;"
 62         "1:"
 63                 "r0 = 0;"
 64                 "exit;"
 65                 ::: __clobber_all);
 66 }
 67 
 68 #if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
 69         (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
 70         defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390)) && \
 71         __clang_major__ >= 18
 72 
 73 SEC("?raw_tp")
 74 __success __log_level(2)
 75 __msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r1 = r10")
 76 __msg("mark_precise: frame0: regs=r2 stack= before 2: (55) if r2 != 0x0 goto pc+2")
 77 __msg("mark_precise: frame0: regs=r2 stack= before 1: (d7) r2 = bswap16 r2")
 78 __msg("mark_precise: frame0: regs=r2 stack= before 0: (b7) r2 = 0")
 79 __naked int bpf_end_bswap(void)
 80 {
 81         asm volatile (
 82                 "r2 = 0;"
 83                 "r2 = bswap16 r2;"
 84                 "if r2 != 0 goto 1f;"
 85                 "r1 = r10;"
 86                 "r1 += r2;"
 87         "1:"
 88                 "r0 = 0;"
 89                 "exit;"
 90                 ::: __clobber_all);
 91 }
 92 
 93 #endif /* v4 instruction */
 94 
 95 SEC("?raw_tp")
 96 __success __log_level(2)
 97 /*
 98  * Without the bug fix there will be no history between "last_idx 3 first_idx 3"
 99  * and "parent state regs=" lines. "R0_w=6" parts are here to help anchor
100  * expected log messages to the one specific mark_chain_precision operation.
101  *
102  * This is quite fragile: if verifier checkpointing heuristic changes, this
103  * might need adjusting.
104  */
105 __msg("2: (07) r0 += 1                       ; R0_w=6")
106 __msg("3: (35) if r0 >= 0xa goto pc+1")
107 __msg("mark_precise: frame0: last_idx 3 first_idx 3 subseq_idx -1")
108 __msg("mark_precise: frame0: regs=r0 stack= before 2: (07) r0 += 1")
109 __msg("mark_precise: frame0: regs=r0 stack= before 1: (07) r0 += 1")
110 __msg("mark_precise: frame0: regs=r0 stack= before 4: (05) goto pc-4")
111 __msg("mark_precise: frame0: regs=r0 stack= before 3: (35) if r0 >= 0xa goto pc+1")
112 __msg("mark_precise: frame0: parent state regs= stack=:  R0_rw=P4")
113 __msg("3: R0_w=6")
114 __naked int state_loop_first_last_equal(void)
115 {
116         asm volatile (
117                 "r0 = 0;"
118         "l0_%=:"
119                 "r0 += 1;"
120                 "r0 += 1;"
121                 /* every few iterations we'll have a checkpoint here with
122                  * first_idx == last_idx, potentially confusing precision
123                  * backtracking logic
124                  */
125                 "if r0 >= 10 goto l1_%=;"       /* checkpoint + mark_precise */
126                 "goto l0_%=;"
127         "l1_%=:"
128                 "exit;"
129                 ::: __clobber_common
130         );
131 }
132 
133 char _license[] SEC("license") = "GPL";
134 

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