diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com | 4 | ||||
-rw-r--r-- | usr/src/cmd/dtrace/test/tst/common/safety/tst.errno.d | 49 | ||||
-rw-r--r-- | usr/src/cmd/dtrace/test/tst/common/safety/tst.gid.d | 49 | ||||
-rw-r--r-- | usr/src/cmd/dtrace/test/tst/common/safety/tst.ppid.d | 49 | ||||
-rw-r--r-- | usr/src/cmd/dtrace/test/tst/common/safety/tst.uid.d | 49 | ||||
-rw-r--r-- | usr/src/uts/common/dtrace/dtrace.c | 34 |
6 files changed, 232 insertions, 2 deletions
diff --git a/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com b/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com index 93b1b75ea9..a320f3b579 100644 --- a/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com +++ b/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com @@ -948,10 +948,13 @@ f none opt/SUNWdtrt/tst/common/safety/tst.cleanpath.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.copyin.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.ddi_pathname.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.dirname.d 0444 root bin +f none opt/SUNWdtrt/tst/common/safety/tst.errno.d 0444 root bin +f none opt/SUNWdtrt/tst/common/safety/tst.gid.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.index.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.msgdsize.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.msgsize.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.null.d 0444 root bin +f none opt/SUNWdtrt/tst/common/safety/tst.ppid.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.progenyof.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.random.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.rw.d 0444 root bin @@ -963,6 +966,7 @@ f none opt/SUNWdtrt/tst/common/safety/tst.strjoin.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.strstr.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.strtok.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.substr.d 0444 root bin +f none opt/SUNWdtrt/tst/common/safety/tst.uid.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.unalign.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.uregs.d 0444 root bin f none opt/SUNWdtrt/tst/common/safety/tst.ustack.d 0444 root bin diff --git a/usr/src/cmd/dtrace/test/tst/common/safety/tst.errno.d b/usr/src/cmd/dtrace/test/tst/common/safety/tst.errno.d new file mode 100644 index 0000000000..d3f238b79e --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/safety/tst.errno.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * collect errno at every fbt probe and at every firing of a + * high-frequency profile probe + */ + +fbt::: +{ + @a[errno] = count(); +} + +profile-4999hz +{ + @a[errno] = count(); +} + +tick-1sec +/n++ == 10/ +{ + exit(0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/safety/tst.gid.d b/usr/src/cmd/dtrace/test/tst/common/safety/tst.gid.d new file mode 100644 index 0000000000..f8f90e7364 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/safety/tst.gid.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * collect gid at every fbt probe and at every firing of a + * high-frequency profile probe + */ + +fbt::: +{ + @a[gid] = count(); +} + +profile-4999hz +{ + @a[gid] = count(); +} + +tick-1sec +/n++ == 10/ +{ + exit(0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/safety/tst.ppid.d b/usr/src/cmd/dtrace/test/tst/common/safety/tst.ppid.d new file mode 100644 index 0000000000..faf07dc482 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/safety/tst.ppid.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * collect ppid at every fbt probe and at every firing of a + * high-frequency profile probe + */ + +fbt::: +{ + @a[ppid] = count(); +} + +profile-4999hz +{ + @a[ppid] = count(); +} + +tick-1sec +/n++ == 10/ +{ + exit(0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/safety/tst.uid.d b/usr/src/cmd/dtrace/test/tst/common/safety/tst.uid.d new file mode 100644 index 0000000000..b546457e78 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/safety/tst.uid.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * collect uid at every fbt probe and at every firing of a + * high-frequency profile probe + */ + +fbt::: +{ + @a[uid] = count(); +} + +profile-4999hz +{ + @a[uid] = count(); +} + +tick-1sec +/n++ == 10/ +{ + exit(0); +} diff --git a/usr/src/uts/common/dtrace/dtrace.c b/usr/src/uts/common/dtrace/dtrace.c index 1e8e7fdb97..c7f655adde 100644 --- a/usr/src/uts/common/dtrace/dtrace.c +++ b/usr/src/uts/common/dtrace/dtrace.c @@ -2494,6 +2494,12 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU)) return (pid0.pid_id); + /* + * It is always safe to dereference one's own t_procp pointer: + * it always points to a valid, allocated proc structure. + * (This is true because threads don't clean up their own + * state -- they leave that task to whomever reaps them.) + */ return ((uint64_t)curthread->t_procp->p_ppid); case DIF_VAR_TID: @@ -2553,7 +2559,16 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU)) return ((uint64_t)p0.p_cred->cr_uid); - return ((uint64_t)curthread->t_cred->cr_uid); + /* + * It is always safe to dereference one's own t_procp pointer: + * it always points to a valid, allocated proc structure. + * (This is true because threads don't clean up their own + * state -- they leave that task to whomever reaps them.) + * + * Additionally, it is safe to dereference one's own process + * credential, since this is never NULL after process birth. + */ + return ((uint64_t)curthread->t_procp->p_cred->cr_uid); case DIF_VAR_GID: if (!dtrace_priv_proc(state)) @@ -2565,7 +2580,16 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU)) return ((uint64_t)p0.p_cred->cr_gid); - return ((uint64_t)curthread->t_cred->cr_gid); + /* + * It is always safe to dereference one's own t_procp pointer: + * it always points to a valid, allocated proc structure. + * (This is true because threads don't clean up their own + * state -- they leave that task to whomever reaps them.) + * + * Additionally, it is safe to dereference one's own process + * credential, since this is never NULL after process birth. + */ + return ((uint64_t)curthread->t_procp->p_cred->cr_gid); case DIF_VAR_ERRNO: { klwp_t *lwp; @@ -2578,6 +2602,12 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU)) return (0); + /* + * It is always safe to dereference one's own t_lwp pointer in + * the event that this pointer is non-NULL. (This is true + * because threads and lwps don't clean up their own state -- + * they leave that task to whomever reaps them.) + */ if ((lwp = curthread->t_lwp) == NULL) return (0); |