summaryrefslogtreecommitdiff
path: root/usr/src/cmd/mdb
diff options
context:
space:
mode:
authorDan McDonald <danmcd@joyent.com>2020-11-17 14:48:44 -0500
committerDan McDonald <danmcd@joyent.com>2020-11-17 14:48:44 -0500
commit2d6415143e9c1044d04ebf846f72f232883413cb (patch)
tree555fae9f2f89b0c9a4d8c4bbd66b02b70ded9fc7 /usr/src/cmd/mdb
parent5a1b3228538dfeb09e05cc2bdfad707ee4d698d7 (diff)
parent5a0af8165ce9590e7a18f1ef4f9badc4dd72c6e6 (diff)
downloadillumos-joyent-release-20201119.tar.gz
[illumos-gate merge]release-20201119
commit 5a0af8165ce9590e7a18f1ef4f9badc4dd72c6e6 13274 enable -fstack-protector-strong by default in user land commit 6a817834d81cc75ce12d0d393320837b1fec1e85 5788 Want support for GCC's stack protector in libc commit 350ffdd54baf880f440ddf9697666e283894ded1 13273 want upanic(2) commit 7fdea60d55a95f0e46066fd021c4ef1b1321bafc 13300 mlxcx_cq_setup() doesn't take required locks for ASSERTs Merge notes: - Manifest changes to match package changes (including shipping libssp_ns.a) - Modified lx_vdso tools to not include SSP, to match other build-only tools.
Diffstat (limited to 'usr/src/cmd/mdb')
-rw-r--r--usr/src/cmd/mdb/Makefile.kmdb5
-rw-r--r--usr/src/cmd/mdb/Makefile.libstand6
-rw-r--r--usr/src/cmd/mdb/Makefile.libstandctf6
-rw-r--r--usr/src/cmd/mdb/Makefile.module1
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_proc.c79
5 files changed, 78 insertions, 19 deletions
diff --git a/usr/src/cmd/mdb/Makefile.kmdb b/usr/src/cmd/mdb/Makefile.kmdb
index be670d3fc6..0bbeaf5200 100644
--- a/usr/src/cmd/mdb/Makefile.kmdb
+++ b/usr/src/cmd/mdb/Makefile.kmdb
@@ -58,6 +58,11 @@ CFLAGS64 += $(STAND_FLAGS_64)
ASFLAGS += -P -D_ASM $(INCDIRS:%=-I%) $(ARCHOPTS)
+#
+# kmdb has bootstrapping challenges with the stack protector.
+#
+STACKPROTECT = none
+
SUBDIR64_sparc = sparcv9
SUBDIR64_i386 = amd64
SUBDIR64 = $(SUBDIR64_$(MACH))
diff --git a/usr/src/cmd/mdb/Makefile.libstand b/usr/src/cmd/mdb/Makefile.libstand
index 9668bbaafb..279194a6ef 100644
--- a/usr/src/cmd/mdb/Makefile.libstand
+++ b/usr/src/cmd/mdb/Makefile.libstand
@@ -66,6 +66,12 @@ $(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG
CPPFLAGS = $(INCDIRS:%=-I%) -D_KMDB
#
+# We cannot currently use the stack protector in kmdb's standalone
+# environment.
+#
+STACKPROTECT = none
+
+#
# kmdb is a kernel module, so we'll use the kernel's build flags.
CFLAGS64 += $(STAND_FLAGS_64)
diff --git a/usr/src/cmd/mdb/Makefile.libstandctf b/usr/src/cmd/mdb/Makefile.libstandctf
index 11e77bafcc..bab6231894 100644
--- a/usr/src/cmd/mdb/Makefile.libstandctf
+++ b/usr/src/cmd/mdb/Makefile.libstandctf
@@ -51,6 +51,12 @@ CSTD = $(CSTD_GNU99)
C99LMODE = -Xc99=%all
#
+# We cannot currently use the stack protector in the kmdb standalone
+# environment.
+#
+STACKPROTECT = none
+
+#
# kmdb is a kernel module, so we'll use the kernel's build flags.
CFLAGS64 += $(STAND_FLAGS_64)
diff --git a/usr/src/cmd/mdb/Makefile.module b/usr/src/cmd/mdb/Makefile.module
index a6305b8ddf..86a9156e18 100644
--- a/usr/src/cmd/mdb/Makefile.module
+++ b/usr/src/cmd/mdb/Makefile.module
@@ -127,6 +127,7 @@ $(MODOBJS) := CFLAGS64 += $(C_BIGPICFLAGS) $(XREGSFLAG)
$(KMODOBJS) := CPPFLAGS += -D_KMDB
$(KMODOBJS) := V9CODESIZE = $(CCABS32)
$(KMODOBJS) := DTS_ERRNO =
+$(KMODFILE) := STACKPROTECT = none
# Modules aren't allowed to export symbols
MAPFILE = $(SRC)/cmd/mdb/common/modules/conf/mapfile
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_proc.c b/usr/src/cmd/mdb/common/mdb/mdb_proc.c
index af4a6eac23..5169cfb6a5 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_proc.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_proc.c
@@ -26,6 +26,7 @@
/*
* Copyright 2018 Joyent, Inc.
* Copyright (c) 2014 by Delphix. All rights reserved.
+ * Copyright 2020 Oxide Computer Company
*/
/*
@@ -103,6 +104,7 @@
#include <stdio_ext.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#define PC_FAKE -1UL /* illegal pc value unequal 0 */
#define PANIC_BUFSIZE 1024
@@ -1574,6 +1576,38 @@ pt_print_reason(const lwpstatus_t *psp)
}
}
+static void
+pt_status_dcmd_upanic(prupanic_t *pru)
+{
+ size_t i;
+
+ mdb_printf("process panicked\n");
+ if ((pru->pru_flags & PRUPANIC_FLAG_MSG_ERROR) != 0) {
+ mdb_printf("warning: process upanic message was bad\n");
+ return;
+ }
+
+ if ((pru->pru_flags & PRUPANIC_FLAG_MSG_VALID) == 0)
+ return;
+
+ if ((pru->pru_flags & PRUPANIC_FLAG_MSG_TRUNC) != 0) {
+ mdb_printf("warning: process upanic message truncated\n");
+ }
+
+ mdb_printf("upanic message: ");
+
+ for (i = 0; i < PRUPANIC_BUFLEN; i++) {
+ if (pru->pru_data[i] == '\0')
+ break;
+ if (isascii(pru->pru_data[i]) && isprint(pru->pru_data[i])) {
+ mdb_printf("%c", pru->pru_data[i]);
+ } else {
+ mdb_printf("\\x%02x", pru->pru_data[i]);
+ }
+ }
+ mdb_printf("\n");
+}
+
/*ARGSUSED*/
static int
pt_status_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
@@ -1591,6 +1625,7 @@ pt_status_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
uintptr_t panicstr;
char *panicbuf = mdb_alloc(PANIC_BUFSIZE, UM_SLEEP);
const siginfo_t *sip = &(psp->pr_lwp.pr_info);
+ prupanic_t *pru = NULL;
char execname[MAXPATHLEN], buf[BUFSIZ];
char signame[SIG2STR_MAX + 4]; /* enough for SIG+name+\0 */
@@ -1696,12 +1731,19 @@ pt_status_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
case PS_DEAD:
if (cursig == 0 && WIFSIGNALED(pi.pr_wstat))
cursig = WTERMSIG(pi.pr_wstat);
+
+ (void) Pupanic(P, &pru);
+
/*
- * We can only use pr_wstat == 0 as a test for gcore if
- * an NT_PRCRED note is present; these features were
- * added at the same time in Solaris 8.
+ * Test for upanic first. We can only use pr_wstat == 0
+ * as a test for gcore if an NT_PRCRED note is present;
+ * these features were added at the same time in Solaris
+ * 8.
*/
- if (pi.pr_wstat == 0 && Pstate(P) == PS_DEAD &&
+ if (pru != NULL) {
+ pt_status_dcmd_upanic(pru);
+ Pupanic_free(pru);
+ } else if (pi.pr_wstat == 0 && Pstate(P) == PS_DEAD &&
Pcred(P, &cred, 1) == 0) {
mdb_printf("process core file generated "
"with gcore(1)\n");
@@ -1747,11 +1789,10 @@ pt_status_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
sym.st_value) == sizeof (panicstr) &&
Pread_string(t->t_pshandle, panicbuf,
PANIC_BUFSIZE, panicstr) > 0) {
- mdb_printf("panic message: %s",
+ mdb_printf("libc panic message: %s",
panicbuf);
}
-
break;
case PS_IDLE:
@@ -4681,27 +4722,27 @@ pt_auxv(mdb_tgt_t *t, const auxv_t **auxvp)
static const mdb_tgt_ops_t proc_ops = {
pt_setflags, /* t_setflags */
- (int (*)())(uintptr_t) mdb_tgt_notsup, /* t_setcontext */
+ (int (*)())(uintptr_t)mdb_tgt_notsup, /* t_setcontext */
pt_activate, /* t_activate */
pt_deactivate, /* t_deactivate */
pt_periodic, /* t_periodic */
pt_destroy, /* t_destroy */
pt_name, /* t_name */
- (const char *(*)()) mdb_conf_isa, /* t_isa */
+ (const char *(*)())mdb_conf_isa, /* t_isa */
pt_platform, /* t_platform */
pt_uname, /* t_uname */
pt_dmodel, /* t_dmodel */
- (ssize_t (*)()) mdb_tgt_notsup, /* t_aread */
- (ssize_t (*)()) mdb_tgt_notsup, /* t_awrite */
+ (ssize_t (*)())mdb_tgt_notsup, /* t_aread */
+ (ssize_t (*)())mdb_tgt_notsup, /* t_awrite */
pt_vread, /* t_vread */
pt_vwrite, /* t_vwrite */
- (ssize_t (*)()) mdb_tgt_notsup, /* t_pread */
- (ssize_t (*)()) mdb_tgt_notsup, /* t_pwrite */
+ (ssize_t (*)())mdb_tgt_notsup, /* t_pread */
+ (ssize_t (*)())mdb_tgt_notsup, /* t_pwrite */
pt_fread, /* t_fread */
pt_fwrite, /* t_fwrite */
- (ssize_t (*)()) mdb_tgt_notsup, /* t_ioread */
- (ssize_t (*)()) mdb_tgt_notsup, /* t_iowrite */
- (int (*)())(uintptr_t) mdb_tgt_notsup, /* t_vtop */
+ (ssize_t (*)())mdb_tgt_notsup, /* t_ioread */
+ (ssize_t (*)())mdb_tgt_notsup, /* t_iowrite */
+ (int (*)())(uintptr_t)mdb_tgt_notsup, /* t_vtop */
pt_lookup_by_name, /* t_lookup_by_name */
pt_lookup_by_addr, /* t_lookup_by_addr */
pt_symbol_iter, /* t_symbol_iter */
@@ -4720,9 +4761,9 @@ static const mdb_tgt_ops_t proc_ops = {
pt_signal, /* t_signal */
pt_add_vbrkpt, /* t_add_vbrkpt */
pt_add_sbrkpt, /* t_add_sbrkpt */
- (int (*)())(uintptr_t) mdb_tgt_null, /* t_add_pwapt */
+ (int (*)())(uintptr_t)mdb_tgt_null, /* t_add_pwapt */
pt_add_vwapt, /* t_add_vwapt */
- (int (*)())(uintptr_t) mdb_tgt_null, /* t_add_iowapt */
+ (int (*)())(uintptr_t)mdb_tgt_null, /* t_add_iowapt */
pt_add_sysenter, /* t_add_sysenter */
pt_add_sysexit, /* t_add_sysexit */
pt_add_signal, /* t_add_signal */
@@ -4848,8 +4889,8 @@ pt_lwp_setfpregs(mdb_tgt_t *t, void *tap, mdb_tgt_tid_t tid,
}
static const pt_ptl_ops_t proc_lwp_ops = {
- (int (*)())(uintptr_t) mdb_tgt_nop,
- (void (*)())(uintptr_t) mdb_tgt_nop,
+ (int (*)())(uintptr_t)mdb_tgt_nop,
+ (void (*)())(uintptr_t)mdb_tgt_nop,
pt_lwp_tid,
pt_lwp_iter,
pt_lwp_getregs,