diff options
Diffstat (limited to 'usr/src')
22 files changed, 365 insertions, 24 deletions
diff --git a/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com b/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com index 21597a9d5f..2f5f88f5d7 100644 --- a/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com +++ b/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com @@ -1350,6 +1350,8 @@ f none opt/SUNWdtrt/tst/common/usdt/tst.user.ksh 0444 root bin f none opt/SUNWdtrt/tst/common/usdt/tst.user.ksh.out 0444 root bin d none opt/SUNWdtrt/tst/common/ustack 0755 root bin f none opt/SUNWdtrt/tst/common/ustack/tst.depth.ksh 0444 root bin +f none opt/SUNWdtrt/tst/common/ustack/tst.bigstack.exe 0555 root bin +f none opt/SUNWdtrt/tst/common/ustack/tst.bigstack.d 0444 root bin f none opt/SUNWdtrt/tst/common/ustack/tst.spin.exe 0555 root bin f none opt/SUNWdtrt/tst/common/ustack/tst.spin.ksh 0444 root bin d none opt/SUNWdtrt/tst/common/vars 0755 root bin diff --git a/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_i386 b/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_i386 index bda4ac9fa0..bc4b742812 100644 --- a/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_i386 +++ b/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_i386 @@ -20,7 +20,7 @@ # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -54,6 +54,8 @@ d none opt/SUNWdtrt/tst/i386/ustack 0755 root bin f none opt/SUNWdtrt/tst/i386/ustack/tst.annotated.d 0444 root bin f none opt/SUNWdtrt/tst/i386/ustack/tst.annotated.d.out 0444 root bin f none opt/SUNWdtrt/tst/i386/ustack/tst.annotated.exe 0555 root bin +f none opt/SUNWdtrt/tst/i386/ustack/tst.circstack.d 0444 root bin +f none opt/SUNWdtrt/tst/i386/ustack/tst.circstack.exe 0555 root bin f none opt/SUNWdtrt/tst/i386/ustack/tst.helper.d 0444 root bin f none opt/SUNWdtrt/tst/i386/ustack/tst.helper.d.out 0444 root bin f none opt/SUNWdtrt/tst/i386/ustack/tst.helper.exe 0555 root bin diff --git a/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_sparc b/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_sparc index 62a2ddb017..4063846067 100644 --- a/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_sparc +++ b/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_sparc @@ -20,7 +20,7 @@ # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" @@ -45,6 +45,8 @@ d none opt/SUNWdtrt/tst/sparc/ustack 0755 root bin f none opt/SUNWdtrt/tst/sparc/ustack/tst.annotated.d 0444 root bin f none opt/SUNWdtrt/tst/sparc/ustack/tst.annotated.d.out 0444 root bin f none opt/SUNWdtrt/tst/sparc/ustack/tst.annotated.exe 0555 root bin +f none opt/SUNWdtrt/tst/sparc/ustack/tst.circstack.d 0444 root bin +f none opt/SUNWdtrt/tst/sparc/ustack/tst.circstack.exe 0555 root bin f none opt/SUNWdtrt/tst/sparc/ustack/tst.helper.d 0444 root bin f none opt/SUNWdtrt/tst/sparc/ustack/tst.helper.d.out 0444 root bin f none opt/SUNWdtrt/tst/sparc/ustack/tst.helper.exe 0555 root bin diff --git a/usr/src/cmd/dtrace/test/tst/common/Makefile b/usr/src/cmd/dtrace/test/tst/common/Makefile index 638fab34bc..77a50a0d4a 100644 --- a/usr/src/cmd/dtrace/test/tst/common/Makefile +++ b/usr/src/cmd/dtrace/test/tst/common/Makefile @@ -36,6 +36,8 @@ proc/tst.sigwait.exe := LIBS += -lrt sysevent/tst.post.exe := LIBS += -lsysevent sysevent/tst.post_chan.exe := LIBS += -lsysevent +ustack/tst.bigstack.exe := COPTFLAG += -xO1 + GCC = /usr/sfw/bin/gcc GCCFLAGS_sparc = -mcpu=ultrasparc GCCFLAGS = $(GCCFLAGS_$(MACH)) diff --git a/usr/src/cmd/dtrace/test/tst/common/ustack/tst.bigstack.c b/usr/src/cmd/dtrace/test/tst/common/ustack/tst.bigstack.c new file mode 100644 index 0000000000..df079dbc2f --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/ustack/tst.bigstack.c @@ -0,0 +1,59 @@ +/* + * 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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +void grow1(int); + +void +grow(int frame) +{ + /* + * Create a ridiculously large stack - enough to push us over + * the default setting of 'dtrace_ustackdepth_max' (2048). + */ + if (frame >= 2048) + for (;;) + getpid(); + + grow1(++frame); +} + +void +grow1(int frame) +{ + grow(++frame); +} + +int +main(int argc, char *argv[]) +{ + grow(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/ustack/tst.bigstack.d b/usr/src/cmd/dtrace/test/tst/common/ustack/tst.bigstack.d new file mode 100644 index 0000000000..1809b1ac00 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/ustack/tst.bigstack.d @@ -0,0 +1,45 @@ +/* + * 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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +syscall::getpid:entry +/pid == $1/ +{ + @[ustackdepth] = count(); +} + +ERROR +/arg4 == DTRACEFLT_BADSTACK/ +{ + exit(0); +} + +profile:::tick-1s +/++n == 10/ +{ + exit(1) +} diff --git a/usr/src/cmd/dtrace/test/tst/i386/ustack/tst.circstack.d b/usr/src/cmd/dtrace/test/tst/i386/ustack/tst.circstack.d new file mode 100644 index 0000000000..79bed7cdf0 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/i386/ustack/tst.circstack.d @@ -0,0 +1,46 @@ +/* + * 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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +syscall::getpid:entry +/pid == $1/ +{ + @[ustackdepth] = count(); +} + +ERROR +/arg4 == DTRACEFLT_BADSTACK/ +{ + exit(0); +} + +profile:::tick-1s +/++n == 10/ +{ + exit(1) +} + diff --git a/usr/src/cmd/dtrace/test/tst/i386/ustack/tst.circstack.s b/usr/src/cmd/dtrace/test/tst/i386/ustack/tst.circstack.s new file mode 100644 index 0000000000..5d6399a97f --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/i386/ustack/tst.circstack.s @@ -0,0 +1,40 @@ +/* + * 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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/asm_linkage.h> + + ENTRY(main) + pushl %ebp + movl %esp, %ebp + movl %esp, (%ebp) +loop: + call getpid + jmp loop + leave + ret + SET_SIZE(main) diff --git a/usr/src/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.d b/usr/src/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.d new file mode 100644 index 0000000000..79bed7cdf0 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.d @@ -0,0 +1,46 @@ +/* + * 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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +syscall::getpid:entry +/pid == $1/ +{ + @[ustackdepth] = count(); +} + +ERROR +/arg4 == DTRACEFLT_BADSTACK/ +{ + exit(0); +} + +profile:::tick-1s +/++n == 10/ +{ + exit(1) +} + diff --git a/usr/src/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.s b/usr/src/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.s new file mode 100644 index 0000000000..dccd236a54 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.s @@ -0,0 +1,41 @@ +/* + * 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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/asm_linkage.h> + + ENTRY(main) + save %sp, -SA(MINFRAME), %sp + mov %sp, %fp +loop: + call getpid + nop + ba loop + nop + ret + restore + SET_SIZE(main) diff --git a/usr/src/cmd/mdb/common/modules/dtrace/dtrace.c b/usr/src/cmd/mdb/common/modules/dtrace/dtrace.c index 21f79e38b6..967ec5b0a5 100644 --- a/usr/src/cmd/mdb/common/modules/dtrace/dtrace.c +++ b/usr/src/cmd/mdb/common/modules/dtrace/dtrace.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1398,6 +1398,7 @@ dtrace_helptrace(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) f == DTRACEFLT_KPRIV ? "KPRIV" : f == DTRACEFLT_UPRIV ? "UPRIV" : f == DTRACEFLT_TUPOFLOW ? "TUPOFLOW" : + f == DTRACEFLT_BADSTACK ? "BADSTACK" : "DTRACEFLT_UNKNOWN"); mdb_printf("%?s| %?s %12s addr: 0x%x\n", "", "", "", help.dtht_illval); diff --git a/usr/src/lib/libdtrace/common/dt_error.c b/usr/src/lib/libdtrace/common/dt_error.c index e8874c853f..5005f593a4 100644 --- a/usr/src/lib/libdtrace/common/dt_error.c +++ b/usr/src/lib/libdtrace/common/dt_error.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -203,6 +203,7 @@ dtrace_faultstr(dtrace_hdl_t *dtp, int fault) { DTRACEFLT_KPRIV, "invalid kernel access" }, { DTRACEFLT_UPRIV, "invalid user access" }, { DTRACEFLT_TUPOFLOW, "tuple stack overflow" }, + { DTRACEFLT_BADSTACK, "bad stack" }, { DTRACEFLT_LIBRARY, "library-level fault" }, { 0, NULL } }; diff --git a/usr/src/lib/libdtrace/common/dt_handle.c b/usr/src/lib/libdtrace/common/dt_handle.c index e6ed51af7d..9d27aee4de 100644 --- a/usr/src/lib/libdtrace/common/dt_handle.c +++ b/usr/src/lib/libdtrace/common/dt_handle.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * 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. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -205,6 +204,7 @@ dt_handle_err(dtrace_hdl_t *dtp, dtrace_probedata_t *data) switch (err.dteda_fault) { case DTRACEFLT_BADADDR: case DTRACEFLT_BADALIGN: + case DTRACEFLT_BADSTACK: (void) sprintf(details, " (0x%llx)", (u_longlong_t)err.dteda_addr); break; diff --git a/usr/src/lib/libdtrace/common/dt_open.c b/usr/src/lib/libdtrace/common/dt_open.c index db7a384b18..53e970df26 100644 --- a/usr/src/lib/libdtrace/common/dt_open.c +++ b/usr/src/lib/libdtrace/common/dt_open.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -100,8 +100,9 @@ #define DT_VERS_1_2_2 DT_VERSION_NUMBER(1, 2, 2) #define DT_VERS_1_3 DT_VERSION_NUMBER(1, 3, 0) #define DT_VERS_1_4 DT_VERSION_NUMBER(1, 4, 0) -#define DT_VERS_LATEST DT_VERS_1_4 -#define DT_VERS_STRING "Sun D 1.4" +#define DT_VERS_1_4_1 DT_VERSION_NUMBER(1, 4, 1) +#define DT_VERS_LATEST DT_VERS_1_4_1 +#define DT_VERS_STRING "Sun D 1.4.1" const dt_version_t _dtrace_versions[] = { DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */ @@ -111,6 +112,7 @@ const dt_version_t _dtrace_versions[] = { DT_VERS_1_2_2, /* D API 1.2.2 Solaris Express 6/06 */ DT_VERS_1_3, /* D API 1.3 Solaris Express 10/06 */ DT_VERS_1_4, /* D API 1.4 Solaris Express 2/07 */ + DT_VERS_1_4_1, /* D API 1.4.1 Solaris Express 4/07 */ 0 }; diff --git a/usr/src/lib/libdtrace/common/unistd.d b/usr/src/lib/libdtrace/common/unistd.d index ce054b1adc..c561ad336a 100644 --- a/usr/src/lib/libdtrace/common/unistd.d +++ b/usr/src/lib/libdtrace/common/unistd.d @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * 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. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -52,3 +51,6 @@ inline int DTRACEFLT_UPRIV = 7; /* Illegal user access */ inline int DTRACEFLT_TUPOFLOW = 8; /* Tuple stack overflow */ #pragma D binding "1.0" DTRACEFLT_TUPOFLOW + +inline int DTRACEFLT_BADSTACK = 9; /* Bad stack */ +#pragma D binding "1.4.1" DTRACEFLT_BADSTACK diff --git a/usr/src/lib/libdtrace_jni/common/dtj_consume.c b/usr/src/lib/libdtrace_jni/common/dtj_consume.c index 8caa49b543..2b9ea0f9fe 100644 --- a/usr/src/lib/libdtrace_jni/common/dtj_consume.c +++ b/usr/src/lib/libdtrace_jni/common/dtj_consume.c @@ -301,6 +301,7 @@ dtj_errhandler(const dtrace_errdata_t *data, void *arg) switch (data->dteda_fault) { case DTRACEFLT_BADADDR: case DTRACEFLT_BADALIGN: + case DTRACEFLT_BADSTACK: addr = data->dteda_addr; break; default: diff --git a/usr/src/lib/libdtrace_jni/common/dtj_error.c b/usr/src/lib/libdtrace_jni/common/dtj_error.c index 7806fe90d4..c0d77da8fa 100644 --- a/usr/src/lib/libdtrace_jni/common/dtj_error.c +++ b/usr/src/lib/libdtrace_jni/common/dtj_error.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -68,6 +68,9 @@ dtj_get_fault_name(int fault) case DTRACEFLT_TUPOFLOW: name = "DTRACEFLT_TUPOFLOW"; break; + case DTRACEFLT_BADSTACK: + name = "DTRACEFLT_BADSTACK"; + break; case DTRACEFLT_LIBRARY: name = "DTRACEFLT_LIBRARY"; break; diff --git a/usr/src/uts/common/dtrace/dtrace.c b/usr/src/uts/common/dtrace/dtrace.c index d384d655d9..eadda9fdbe 100644 --- a/usr/src/uts/common/dtrace/dtrace.c +++ b/usr/src/uts/common/dtrace/dtrace.c @@ -435,6 +435,7 @@ dtrace_load##bits(uintptr_t addr) \ ((flags) & CPU_DTRACE_TUPOFLOW) ? DTRACEFLT_TUPOFLOW : \ ((flags) & CPU_DTRACE_BADALIGN) ? DTRACEFLT_BADALIGN : \ ((flags) & CPU_DTRACE_NOSCRATCH) ? DTRACEFLT_NOSCRATCH : \ + ((flags) & CPU_DTRACE_BADSTACK) ? DTRACEFLT_BADSTACK : \ DTRACEFLT_UNKNOWN) #define DTRACEACT_ISSTRING(act) \ diff --git a/usr/src/uts/common/sys/cpuvar.h b/usr/src/uts/common/sys/cpuvar.h index f3dc26f874..c211b63185 100644 --- a/usr/src/uts/common/sys/cpuvar.h +++ b/usr/src/uts/common/sys/cpuvar.h @@ -329,11 +329,13 @@ extern cpu_core_t cpu_core[]; #define CPU_DTRACE_FAKERESTORE 0x0400 /* pid provider hint to getreg */ #endif #define CPU_DTRACE_ENTRY 0x0800 /* pid provider hint to ustack() */ +#define CPU_DTRACE_BADSTACK 0x1000 /* DTrace fault: bad stack */ #define CPU_DTRACE_FAULT (CPU_DTRACE_BADADDR | CPU_DTRACE_BADALIGN | \ CPU_DTRACE_DIVZERO | CPU_DTRACE_ILLOP | \ CPU_DTRACE_NOSCRATCH | CPU_DTRACE_KPRIV | \ - CPU_DTRACE_UPRIV | CPU_DTRACE_TUPOFLOW) + CPU_DTRACE_UPRIV | CPU_DTRACE_TUPOFLOW | \ + CPU_DTRACE_BADSTACK) #define CPU_DTRACE_ERROR (CPU_DTRACE_FAULT | CPU_DTRACE_DROP) /* diff --git a/usr/src/uts/common/sys/dtrace.h b/usr/src/uts/common/sys/dtrace.h index 1c76417830..a42d69a677 100644 --- a/usr/src/uts/common/sys/dtrace.h +++ b/usr/src/uts/common/sys/dtrace.h @@ -1067,6 +1067,7 @@ typedef struct dtrace_conf { #define DTRACEFLT_KPRIV 6 /* Illegal kernel access */ #define DTRACEFLT_UPRIV 7 /* Illegal user access */ #define DTRACEFLT_TUPOFLOW 8 /* Tuple stack overflow */ +#define DTRACEFLT_BADSTACK 9 /* Bad stack */ #define DTRACEFLT_LIBRARY 1000 /* Library-level fault */ diff --git a/usr/src/uts/intel/dtrace/dtrace_isa.c b/usr/src/uts/intel/dtrace/dtrace_isa.c index 4baf88c31f..afed21d7b2 100644 --- a/usr/src/uts/intel/dtrace/dtrace_isa.c +++ b/usr/src/uts/intel/dtrace/dtrace_isa.c @@ -35,6 +35,8 @@ extern uintptr_t kernelbase; +int dtrace_ustackdepth_max = 2048; + void dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, uint32_t *intrpc) @@ -113,12 +115,14 @@ dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t pc, klwp_t *lwp = ttolwp(curthread); proc_t *p = curproc; uintptr_t oldcontext = lwp->lwp_oldcontext; + uintptr_t oldsp; volatile uint16_t *flags = (volatile uint16_t *)&cpu_core[CPU->cpu_id].cpuc_dtrace_flags; size_t s1, s2; int ret = 0; ASSERT(pcstack == NULL || pcstack_limit > 0); + ASSERT(dtrace_ustackdepth_max > 0); if (p->p_model == DATAMODEL_NATIVE) { s1 = sizeof (struct frame) + 2 * sizeof (long); @@ -129,7 +133,16 @@ dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t pc, } while (pc != 0) { - ret++; + /* + * We limit the number of times we can go around this + * loop to account for a circular stack. + */ + if (ret++ >= dtrace_ustackdepth_max) { + *flags |= CPU_DTRACE_BADSTACK; + cpu_core[CPU->cpu_id].cpuc_dtrace_illval = sp; + break; + } + if (pcstack != NULL) { *pcstack++ = (uint64_t)pc; pcstack_limit--; @@ -140,6 +153,8 @@ dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t pc, if (sp == 0) break; + oldsp = sp; + if (oldcontext == sp + s1 || oldcontext == sp + s2) { if (p->p_model == DATAMODEL_NATIVE) { ucontext_t *ucp = (ucontext_t *)oldcontext; @@ -172,6 +187,12 @@ dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t pc, } } + if (sp == oldsp) { + *flags |= CPU_DTRACE_BADSTACK; + cpu_core[CPU->cpu_id].cpuc_dtrace_illval = sp; + break; + } + /* * This is totally bogus: if we faulted, we're going to clear * the fault and break. This is to deal with the apparently diff --git a/usr/src/uts/sparc/dtrace/dtrace_isa.c b/usr/src/uts/sparc/dtrace/dtrace_isa.c index 627cef869e..50b1f49ea7 100644 --- a/usr/src/uts/sparc/dtrace/dtrace_isa.c +++ b/usr/src/uts/sparc/dtrace/dtrace_isa.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * 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. @@ -21,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -66,6 +65,8 @@ extern ulong_t dtrace_getreg_win(uint_t, uint_t); extern void dtrace_putreg_win(uint_t, ulong_t); extern int dtrace_fish(int, int, uintptr_t *); +int dtrace_ustackdepth_max = 2048; + /* * This is similar in principle to getpcstack(), but there are several marked * differences in implementation: @@ -361,8 +362,12 @@ dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t sp) { proc_t *p = curproc; int ret = 0; + uintptr_t oldsp; + volatile uint16_t *flags = + (volatile uint16_t *)&cpu_core[CPU->cpu_id].cpuc_dtrace_flags; ASSERT(pcstack == NULL || pcstack_limit > 0); + ASSERT(dtrace_ustackdepth_max > 0); if (p->p_model == DATAMODEL_NATIVE) { for (;;) { @@ -373,13 +378,23 @@ dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t sp) !IS_P2ALIGNED((uintptr_t)fr, STACK_ALIGN)) break; + oldsp = sp; + pc = dtrace_fulword(&fr->fr_savpc); sp = dtrace_fulword(&fr->fr_savfp); if (pc == 0) break; - ret++; + /* + * We limit the number of times we can go around this + * loop to account for a circular stack. + */ + if (sp == oldsp || ret++ >= dtrace_ustackdepth_max) { + *flags |= CPU_DTRACE_BADSTACK; + cpu_core[CPU->cpu_id].cpuc_dtrace_illval = sp; + break; + } if (pcstack != NULL) { *pcstack++ = pc; @@ -404,13 +419,19 @@ dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t sp) !IS_P2ALIGNED((uintptr_t)fr, STACK_ALIGN32)) break; + oldsp = sp; + pc = dtrace_fuword32(&fr->fr_savpc); sp = dtrace_fuword32(&fr->fr_savfp); if (pc == 0) break; - ret++; + if (sp == oldsp || ret++ >= dtrace_ustackdepth_max) { + *flags |= CPU_DTRACE_BADSTACK; + cpu_core[CPU->cpu_id].cpuc_dtrace_illval = sp; + break; + } if (pcstack != NULL) { *pcstack++ = pc; |