2 # This file and its contents are supplied under the terms of the
3 # Common Development and Distribution License ("CDDL"), version 1.0.
4 # You may only use this file in accordance with the terms of version
7 # A full copy of the text of the CDDL should have accompanied this
8 # source. A copy of the CDDL is also available via the Internet at
9 # http://www.illumos.org/license/CDDL.
13 # Copyright (c) 2015, Joyent, Inc. All rights reserved.
18 ppriv
-s A
=basic
,dtrace_user $$
21 # When we lack dtrace_kernel, we expect to not be able to get at kernel memory
22 # via any subroutine or other vector.
24 # trace(func((void *)&\`utsname)); }
25 /usr
/sbin
/dtrace
-wq -Cs /dev
/stdin
2> $err <<EOF
28 printf("able to read kernel memory via %s!\n", badsubr); \
31 #define CANTREAD1(func) \
32 BEGIN { badsubr = "func()"; func((void *)&\`utsname); FAIL }
34 #define CANTREAD2(func, arg1) \
35 BEGIN { badsubr = "func()"; func((void *)&\`utsname, arg1); FAIL }
37 #define CANTREAD2ARG1(func, arg0) \
38 BEGIN { badsubr = "func() (arg1)"; func(arg0, (void *)&\`utsname); FAIL }
40 #define CANTREAD3(func, arg1, arg2) \
41 BEGIN { badsubr = "func()"; func((void *)&\`utsname, arg1, arg2); FAIL }
43 CANTREAD1(mutex_owned)
44 CANTREAD1(mutex_owner)
45 CANTREAD1(mutex_type_adaptive)
46 CANTREAD1(mutex_type_spin)
47 CANTREAD1(rw_read_held)
48 CANTREAD1(rw_write_held)
49 CANTREAD1(rw_iswriter)
50 CANTREAD3(bcopy, alloca(1), 1)
54 CANTREAD2(strchr, '!')
55 CANTREAD2(strrchr, '!')
56 CANTREAD2(strstr, "doogle")
57 CANTREAD2ARG1(strstr, "doogle")
58 CANTREAD2(index, "bagnoogle")
59 CANTREAD2ARG1(index, "bagnoogle")
60 CANTREAD2(rindex, "bagnoogle")
61 CANTREAD2ARG1(rindex, "bagnoogle")
62 CANTREAD2(strtok, "doogle")
63 CANTREAD2ARG1(strtok, "doogle")
64 CANTREAD2(json, "doogle")
65 CANTREAD2ARG1(json, "doogle")
68 CANTREAD2(ddi_pathname, 1)
69 CANTREAD2(strjoin, "doogle")
70 CANTREAD2ARG1(strjoin, "doogle")
77 CANTREAD3(copyout, uregs[R_R9], 1)
78 CANTREAD3(copyoutstr, uregs[R_R9], 1)
81 CANTREAD3(copyout, uregs[R_ESP], 1)
82 CANTREAD3(copyoutstr, uregs[R_ESP], 1)
92 /arg4 != DTRACEFLT_KPRIV/
94 printf("bad error code via %s (expected %d, found %d)\n",
95 badsubr, DTRACEFLT_KPRIV, arg4);
100 /arg4 == DTRACEFLT_KPRIV/
102 printf("illegal kernel access properly prevented from %s\n", badsubr);
108 if [[ $status -eq 1 ]]; then