diff options
author | Renato Botelho <renato@netgate.com> | 2017-02-23 06:28:41 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-02-23 06:28:41 -0300 |
commit | 82ceeb2ea625cd9bff60f2863b9a0830f55b7905 (patch) | |
tree | 263ca9347bf664a4489743f9302e699ce14de1df /cddl/contrib/opensolaris | |
parent | 4a05f5440acda223e6a0ec5157bc32ecc0f09ff9 (diff) | |
parent | d20dd8b36e7a565be7bfbb22aade51c8ffd753e9 (diff) | |
download | FreeBSD-src-devel.zip FreeBSD-src-devel.tar.gz |
Merge remote-tracking branch 'origin/stable/10' into develdevel
Diffstat (limited to 'cddl/contrib/opensolaris')
24 files changed, 198 insertions, 18 deletions
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.c index 3cded11..9b878a2 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.c @@ -26,6 +26,8 @@ #pragma ident "%Z%%M% %I% %E% SMI" +#include <sys/ioctl.h> + #include <assert.h> #include <setjmp.h> #include <signal.h> @@ -69,7 +71,7 @@ main(int argc, char *argv[]) */ if (sigsetjmp(env, 1) == 0) { for (;;) - (void) ioctl(-1, -1, NULL); + (void) ioctl(-1, 0, NULL); } /* @@ -80,20 +82,19 @@ main(int argc, char *argv[]) fds[n++] = open(file, O_WRONLY); fds[n++] = open(file, O_RDWR); - fds[n++] = open(file, O_RDWR | O_APPEND | O_CREAT | O_DSYNC | - O_LARGEFILE | O_NOCTTY | O_NONBLOCK | O_NDELAY | O_RSYNC | - O_SYNC | O_TRUNC | O_XATTR, 0666); + fds[n++] = open(file, O_RDWR | O_APPEND | O_CREAT | + O_NOCTTY | O_NONBLOCK | O_NDELAY | O_SYNC | O_TRUNC | 0666); fds[n++] = open(file, O_RDWR); (void) lseek(fds[n - 1], 123, SEEK_SET); /* * Once we have all the file descriptors in the state we want to test, - * issue a bogus ioctl() on each fd with cmd -1 and arg NULL to whack + * issue a bogus ioctl() on each fd with cmd 0 and arg NULL to whack * our DTrace script into recording the content of the fds[] array. */ for (i = 0; i < n; i++) - (void) ioctl(fds[i], -1, NULL); + (void) ioctl(fds[i], 0, NULL); assert(n <= sizeof (fds) / sizeof (fds[0])); exit(0); diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d index 52a3312..8685142 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d @@ -36,7 +36,7 @@ syscall::ioctl:entry } syscall::ioctl:entry -/pid == $1 && arg0 != -1u && arg1 == -1u && arg2 == NULL/ +/pid == $1 && arg0 != -1u && arg1 == 0 && arg2 == NULL/ { printf("fds[%d] fi_name = %s\n", arg0, fds[arg0].fi_name); printf("fds[%d] fi_dirname = %s\n", arg0, fds[arg0].fi_dirname); diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/json/tst.usdt.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/json/tst.usdt.c index 307106d..2a54d49 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/json/tst.usdt.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/json/tst.usdt.c @@ -14,6 +14,8 @@ */ #include <sys/sdt.h> +#include <stdio.h> +#include <stdlib.h> #include "usdt.h" #define FMT "{" \ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/nfs/tst.call3.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/nfs/tst.call3.c index bd89fff..dda3ef2 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/nfs/tst.call3.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/nfs/tst.call3.c @@ -28,6 +28,7 @@ #include <strings.h> #include <rpc/rpc.h> +#include <stdio.h> #include <stdlib.h> #include <sys/param.h> #include <rpcsvc/mount.h> diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.args1.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.args1.c index 23bbab2..28d0677 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.args1.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.args1.c @@ -27,6 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include <signal.h> +#include <stdlib.h> #include <unistd.h> int diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.gcc.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.gcc.c index 69df472..b3959c3 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.gcc.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.gcc.c @@ -26,6 +26,8 @@ #pragma ident "%Z%%M% %I% %E% SMI" +#include <sys/types.h> +#include <sys/wait.h> #include <spawn.h> #include <signal.h> #include <stdio.h> diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret1.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret1.c index cfb88a8..12b3f72 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret1.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret1.c @@ -27,6 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include <signal.h> +#include <stdlib.h> #include <unistd.h> /* diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret2.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret2.c index b64aa05..ea5394e 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret2.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret2.c @@ -27,6 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include <signal.h> +#include <stdlib.h> #include <unistd.h> /* diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak1.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak1.c index 1418f2a..765c285 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak1.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak1.c @@ -27,6 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include <signal.h> +#include <stdlib.h> #include <unistd.h> /* diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c index 8dabbe6..756745d 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c @@ -27,6 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include <signal.h> +#include <stdlib.h> #include <unistd.h> /* @@ -34,14 +35,14 @@ * leading underscores. */ -#pragma weak _go = go - static int go(int a) { return (a + 1); } +#pragma weak _go = go + static void handle(int sig) { diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d index 8d4bb81..10dc61d 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d @@ -44,7 +44,7 @@ BEGIN printf("\n"); - printf("%%a = %a\n", &`kmem_alloc); + printf("%%a = %a\n", &`malloc); printf("%%c = %c\n", i); printf("%%d = %d\n", i); printf("%%hd = %hd\n", (short)i); diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d.out index 55c1222..1d27405 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d.out +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d.out @@ -1,5 +1,5 @@ -%a = genunix`kmem_alloc +%a = kernel`malloc %c = a %d = 97 %hd = 97 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d index a740413..67d7749 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d @@ -36,6 +36,6 @@ BEGIN { - printf("sysname = %s", `utsname.sysname); + printf("sysname = %s", `ostype); exit(0); } diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d.out index ba31981..82d597b 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d.out +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d.out @@ -1 +1 @@ -sysname = SunOS +sysname = FreeBSD diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d index 32bc682..c2cf77d 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d @@ -38,6 +38,6 @@ BEGIN { - printf("symbol = %a", &`kmem_alloc); + printf("symbol = %a", &`malloc); exit(0); } diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d.out index 5ed9d8e..7f645e1 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d.out +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d.out @@ -1 +1 @@ -symbol = kernel`kmem_alloc +symbol = kernel`malloc diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/privs/tst.kpriv.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/privs/tst.kpriv.ksh new file mode 100644 index 0000000..da776d0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/privs/tst.kpriv.ksh @@ -0,0 +1,112 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2015, Joyent, Inc. All rights reserved. +# + +err=/tmp/err.$$ + +ppriv -s A=basic,dtrace_user $$ + +# +# When we lack dtrace_kernel, we expect to not be able to get at kernel memory +# via any subroutine or other vector. +# +# trace(func((void *)&\`utsname)); } +/usr/sbin/dtrace -wq -Cs /dev/stdin 2> $err <<EOF + +#define FAIL \ + printf("able to read kernel memory via %s!\n", badsubr); \ + exit(2); + +#define CANTREAD1(func) \ + BEGIN { badsubr = "func()"; func((void *)&\`utsname); FAIL } + +#define CANTREAD2(func, arg1) \ + BEGIN { badsubr = "func()"; func((void *)&\`utsname, arg1); FAIL } + +#define CANTREAD2ARG1(func, arg0) \ + BEGIN { badsubr = "func() (arg1)"; func(arg0, (void *)&\`utsname); FAIL } + +#define CANTREAD3(func, arg1, arg2) \ + BEGIN { badsubr = "func()"; func((void *)&\`utsname, arg1, arg2); FAIL } + +CANTREAD1(mutex_owned) +CANTREAD1(mutex_owner) +CANTREAD1(mutex_type_adaptive) +CANTREAD1(mutex_type_spin) +CANTREAD1(rw_read_held) +CANTREAD1(rw_write_held) +CANTREAD1(rw_iswriter) +CANTREAD3(bcopy, alloca(1), 1) +CANTREAD1(msgsize) +CANTREAD1(msgdsize) +CANTREAD1(strlen) +CANTREAD2(strchr, '!') +CANTREAD2(strrchr, '!') +CANTREAD2(strstr, "doogle") +CANTREAD2ARG1(strstr, "doogle") +CANTREAD2(index, "bagnoogle") +CANTREAD2ARG1(index, "bagnoogle") +CANTREAD2(rindex, "bagnoogle") +CANTREAD2ARG1(rindex, "bagnoogle") +CANTREAD2(strtok, "doogle") +CANTREAD2ARG1(strtok, "doogle") +CANTREAD2(json, "doogle") +CANTREAD2ARG1(json, "doogle") +CANTREAD1(toupper) +CANTREAD1(tolower) +CANTREAD2(ddi_pathname, 1) +CANTREAD2(strjoin, "doogle") +CANTREAD2ARG1(strjoin, "doogle") +CANTREAD1(strtoll) +CANTREAD1(dirname) +CANTREAD1(basename) +CANTREAD1(cleanpath) + +#if defined(__amd64) +CANTREAD3(copyout, uregs[R_R9], 1) +CANTREAD3(copyoutstr, uregs[R_R9], 1) +#else +#if defined(__i386) +CANTREAD3(copyout, uregs[R_ESP], 1) +CANTREAD3(copyoutstr, uregs[R_ESP], 1) +#endif +#endif + +BEGIN +{ + exit(0); +} + +ERROR +/arg4 != DTRACEFLT_KPRIV/ +{ + printf("bad error code via %s (expected %d, found %d)\n", + badsubr, DTRACEFLT_KPRIV, arg4); + exit(3); +} + +ERROR +/arg4 == DTRACEFLT_KPRIV/ +{ + printf("illegal kernel access properly prevented from %s\n", badsubr); +} +EOF + +status=$? + +if [[ $status -eq 1 ]]; then + cat $err +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.ufunc.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.ufunc.ksh index 69c0f84..d2afbed 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.ufunc.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.ufunc.ksh @@ -64,7 +64,7 @@ child=$! # ksh doing work. (This actually goes one step further and assumes that we # catch some non-static function in ksh.) # -script | tee /dev/fd/2 | grep 'ksh`[a-zA-Z_]' > /dev/null +script | tee /dev/fd/2 | egrep 'ksh(93)?`[a-zA-Z_]' > /dev/null status=$? kill $child diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.umod.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.umod.ksh index 6ca823f..8be34ec 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.umod.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.umod.ksh @@ -62,7 +62,7 @@ child=$! # # The only thing we can be sure of here is that ksh is doing some work. # -script | tee /dev/fd/2 | grep -w ksh > /dev/null +script | tee /dev/fd/2 | egrep -w 'ksh(93)?' > /dev/null status=$? kill $child diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh index b1a3ab9..8842d2b 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh @@ -63,7 +63,7 @@ child=$! # This test is essentially the same as that in the ufunc test; see that # test for the rationale. # -script | tee /dev/fd/2 | grep 'ksh`[a-zA-Z_]' > /dev/null +script | tee /dev/fd/2 | egrep 'ksh(93)?`[a-zA-Z_]' > /dev/null status=$? kill $child diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.bigglobal.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.bigglobal.d new file mode 100644 index 0000000..a50a759 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.bigglobal.d @@ -0,0 +1,26 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2015, Joyent, Inc. All rights reserved. + */ + +struct mrbig { + char toomany[100000]; +}; + +struct mrbig mrbig; + +BEGIN +{ + mrbig.toomany[0] = '!'; + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.biglocal.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.biglocal.d new file mode 100644 index 0000000..08a2a4c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.biglocal.d @@ -0,0 +1,26 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2015, Joyent, Inc. All rights reserved. + */ + +struct mrbig { + char toomany[100000]; +}; + +this struct mrbig mrbig; + +BEGIN +{ + this->mrbig.toomany[0] = '!'; + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/syscall/tst.args.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/syscall/tst.args.c index 209160b..198d9db 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/syscall/tst.args.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/syscall/tst.args.c @@ -28,6 +28,7 @@ #include <stdio.h> #include <sys/syscall.h> +#include <unistd.h> /*ARGSUSED*/ int diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.forker.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.forker.c index ade7f83..e229c0c 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.forker.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.forker.c @@ -26,6 +26,10 @@ #pragma ident "%Z%%M% %I% %E% SMI" +#include <sys/types.h> +#include <sys/wait.h> + +#include <stdlib.h> #include <unistd.h> #include "forker.h" |