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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc

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 #!/bin/sh
  2 # SPDX-License-Identifier: GPL-2.0
  3 # description: Kprobe event argument syntax
  4 # requires: kprobe_events "x8/16/32/64":README
  5 
  6 PROBEFUNC="vfs_read"
  7 GOODREG=
  8 BADREG=
  9 GOODSYM="_sdata"
 10 if ! grep -qw ${GOODSYM} /proc/kallsyms ; then
 11   GOODSYM=$PROBEFUNC
 12 fi
 13 BADSYM="deaqswdefr"
 14 SYMADDR=0x`grep -w ${GOODSYM} /proc/kallsyms | cut -f 1 -d " "`
 15 GOODTYPE="x16"
 16 BADTYPE="y16"
 17 
 18 case `uname -m` in
 19 x86_64|i[3456]86)
 20   GOODREG=%ax
 21   BADREG=%ex
 22 ;;
 23 aarch64)
 24   GOODREG=%x0
 25   BADREG=%ax
 26 ;;
 27 arm*)
 28   GOODREG=%r0
 29   BADREG=%ax
 30 ;;
 31 ppc*)
 32   GOODREG=%r3
 33   BADREG=%msr
 34 ;;
 35 s390*)
 36   GOODREG=%r2
 37   BADREG=%s2
 38 ;;
 39 mips*)
 40   GOODREG=%r4
 41   BADREG=%r12
 42 ;;
 43 loongarch*)
 44   GOODREG=%r4
 45   BADREG=%r12
 46 ;;
 47 riscv*)
 48   GOODREG=%a0
 49   BADREG=%a8
 50 ;;
 51 *)
 52   echo "Please implement other architecture here"
 53   exit_untested
 54 esac
 55 
 56 test_goodarg() # Good-args
 57 {
 58   while [ "$1" ]; do
 59     echo "p ${PROBEFUNC} $1" > kprobe_events
 60     shift 1
 61   done;
 62 }
 63 
 64 test_badarg() # Bad-args
 65 {
 66   while [ "$1" ]; do
 67     ! echo "p ${PROBEFUNC} $1" > kprobe_events
 68     shift 1
 69   done;
 70 }
 71 
 72 echo > kprobe_events
 73 
 74 : "Register access"
 75 test_goodarg ${GOODREG}
 76 test_badarg ${BADREG}
 77 
 78 : "Symbol access"
 79 test_goodarg "@${GOODSYM}" "@${SYMADDR}" "@${GOODSYM}+10" "@${GOODSYM}-10"
 80 test_badarg "@" "@${BADSYM}" "@${GOODSYM}*10" "@${GOODSYM}/10" \
 81             "@${GOODSYM}%10" "@${GOODSYM}&10" "@${GOODSYM}|10"
 82 
 83 : "Stack access"
 84 test_goodarg "\$stack" "\$stack0" "\$stack1"
 85 test_badarg "\$stackp" "\$stack0+10" "\$stack1-10"
 86 
 87 : "Retval access"
 88 echo "r ${PROBEFUNC} \$retval" > kprobe_events
 89 ! echo "p ${PROBEFUNC} \$retval" > kprobe_events
 90 
 91 # $comm was introduced in 4.8, older kernels reject it.
 92 if grep -A1 "fetcharg:" README | grep -q '\$comm' ; then
 93 : "Comm access"
 94 test_goodarg "\$comm"
 95 fi
 96 
 97 : "Indirect memory access"
 98 test_goodarg "+0(${GOODREG})" "-0(${GOODREG})" "+10(\$stack)" \
 99         "+0(\$stack1)" "+10(@${GOODSYM}-10)" "+0(+10(+20(\$stack)))"
100 test_badarg "+(${GOODREG})" "(${GOODREG}+10)" "-(${GOODREG})" "(${GOODREG})" \
101         "+10(\$comm)" "+0(${GOODREG})+10"
102 
103 : "Name assignment"
104 test_goodarg "varname=${GOODREG}"
105 test_badarg "varname=varname2=${GOODREG}"
106 
107 : "Type syntax"
108 test_goodarg "${GOODREG}:${GOODTYPE}"
109 test_badarg "${GOODREG}::${GOODTYPE}" "${GOODREG}:${BADTYPE}" \
110         "${GOODTYPE}:${GOODREG}"
111 
112 : "Combination check"
113 
114 test_goodarg "\$comm:string" "+0(\$stack):string"
115 test_badarg "\$comm:x64" "\$stack:string" "${GOODREG}:string"

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