summaryrefslogtreecommitdiff
path: root/usr/src/cmd
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
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')
-rw-r--r--usr/src/cmd/Makefile.cmd8
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/pppd/plugins/Makefile9
-rw-r--r--usr/src/cmd/lp/cmd/Makefile9
-rw-r--r--usr/src/cmd/lp/cmd/lpadmin/Makefile2
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/Makefile6
-rw-r--r--usr/src/cmd/lp/model/Makefile6
-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
-rw-r--r--usr/src/cmd/picl/plugins/common/piclevent/Makefile2
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/Makefile8
-rw-r--r--usr/src/cmd/rcm_daemon/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/elfdump/common/corenote.c102
-rw-r--r--usr/src/cmd/sgs/elfdump/common/elfdump.msg5
-rw-r--r--usr/src/cmd/sgs/elfdump/common/gen_layout_obj.c1
-rw-r--r--usr/src/cmd/sgs/elfdump/common/gen_struct_layout.c12
-rw-r--r--usr/src/cmd/sgs/elfdump/common/struct_layout.h8
-rw-r--r--usr/src/cmd/sgs/elfdump/common/struct_layout_amd64.c9
-rw-r--r--usr/src/cmd/sgs/elfdump/common/struct_layout_i386.c9
-rw-r--r--usr/src/cmd/sgs/elfdump/common/struct_layout_sparc.c9
-rw-r--r--usr/src/cmd/sgs/elfdump/common/struct_layout_sparcv9.c9
-rw-r--r--usr/src/cmd/sgs/include/conv.h12
-rw-r--r--usr/src/cmd/sgs/libconv/Makefile.com6
-rw-r--r--usr/src/cmd/sgs/libconv/common/corenote.c76
-rw-r--r--usr/src/cmd/sgs/libconv/common/corenote.msg18
-rw-r--r--usr/src/cmd/sgs/rtld/Makefile.com16
-rw-r--r--usr/src/cmd/truss/main.c9
-rw-r--r--usr/src/cmd/truss/systable.c3
30 files changed, 374 insertions, 79 deletions
diff --git a/usr/src/cmd/Makefile.cmd b/usr/src/cmd/Makefile.cmd
index b16a7532b2..b616d6a7ac 100644
--- a/usr/src/cmd/Makefile.cmd
+++ b/usr/src/cmd/Makefile.cmd
@@ -115,7 +115,13 @@ ROOTAUDIOSAMPAU=$(ROOTAUDIOSAMP)/au
ISAEXEC= $(ROOT)/usr/lib/isaexec
PLATEXEC= $(ROOT)/usr/lib/platexec
-LDLIBS = $(LDLIBS.cmd)
+#
+# Enable the stack protector by default.
+#
+CFLAGS += $(CCSTACKPROTECT)
+CFLAGS64 += $(CCSTACKPROTECT)
+
+LDLIBS = $(LDLIBS.cmd) $(LDSTACKPROTECT)
LDFLAGS.cmd = \
$(BDIRECT) $(ENVLDFLAGS1) $(ENVLDFLAGS2) $(ENVLDFLAGS3) \
diff --git a/usr/src/cmd/cmd-inet/usr.bin/pppd/plugins/Makefile b/usr/src/cmd/cmd-inet/usr.bin/pppd/plugins/Makefile
index d577640c90..1f7c9b1ef7 100644
--- a/usr/src/cmd/cmd-inet/usr.bin/pppd/plugins/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.bin/pppd/plugins/Makefile
@@ -26,7 +26,7 @@
#
MINCONN = minconn.so
-PASSPROMPT = passprompt.so
+PASSPROMPT = passprompt.so
PPPOE = pppoe.so
LIBRARIES = minconn.so passprompt.so pppoe.so
@@ -52,11 +52,8 @@ $(MINCONN):= MAPFILES = mapfile-minconn
$(PASSPROMPT):= MAPFILES = mapfile-passprompt
$(PPPOE):= MAPFILES = mapfile-pppoe
-# A bug in pmake causes redundancy when '+=' is conditionally assigned, so
-# '=' is used with extra variables.
-XXXLDLIBS =
-$(PASSPROMPT):= XXXLDLIBS = -lc
-LDLIBS += $(XXXLDLIBS)
+$(PASSPROMPT):= LDLIBS += -lc
+$(PPPOE):= LDLIBS += -lc
CPPFLAGS += -I.. -I$(SRC)/uts/common
# XX64 -- this should not be needed -- fix me
diff --git a/usr/src/cmd/lp/cmd/Makefile b/usr/src/cmd/lp/cmd/Makefile
index 1d31e19262..21fef0076b 100644
--- a/usr/src/cmd/lp/cmd/Makefile
+++ b/usr/src/cmd/lp/cmd/Makefile
@@ -54,11 +54,12 @@ LDFLAGS += $(MAPFILE.NGB:%=-Wl,-M%)
# conditional assignments
#
lpfilter:= LDLIBS += $(LIBFLT) $(LIBMSG) $(LIBACC) $(LIBOAM) $(LIBLP) \
- -lgen -lsecdb
+ -lgen -lsecdb $(LDSTACKPROTECT)
lpforms:= LDLIBS += $(LIBFRM) $(LIBMSG) $(LIBREQ) $(LIBOAM) \
- $(LIBACC) $(LIBLP) -lsecdb
-lpshut:= LDLIBS += $(LIBMSG) $(LIBOAM) $(LIBLP)
-lpusers:= LDLIBS += $(LIBMSG) $(LIBACC) $(LIBOAM) $(LIBUSR) $(LIBLP)
+ $(LIBACC) $(LIBLP) -lsecdb $(LDSTACKPROTECT)
+lpshut:= LDLIBS += $(LIBMSG) $(LIBOAM) $(LIBLP) $(LDSTACKPROTECT)
+lpusers:= LDLIBS += $(LIBMSG) $(LIBACC) $(LIBOAM) $(LIBUSR) $(LIBLP) \
+ $(LDSTACKPROTECT)
.KEEP_STATE:
diff --git a/usr/src/cmd/lp/cmd/lpadmin/Makefile b/usr/src/cmd/lp/cmd/lpadmin/Makefile
index 4e2333ce29..ca2753b1e2 100644
--- a/usr/src/cmd/lp/cmd/lpadmin/Makefile
+++ b/usr/src/cmd/lp/cmd/lpadmin/Makefile
@@ -62,7 +62,7 @@ LPLIBS= $(LIBACC) \
SYSLIBS= -lcurses
-LDLIBS += -lsecdb $(LPLIBS) $(SYSLIBS) $(I18N)
+LDLIBS += -lsecdb $(LPLIBS) $(SYSLIBS) $(I18N) $(LDSTACKPROTECT)
LDFLAGS += $(MAPFILE.NGB:%=-Wl,-M%)
PROG= lpadmin
diff --git a/usr/src/cmd/lp/cmd/lpsched/Makefile b/usr/src/cmd/lp/cmd/lpsched/Makefile
index c5c645ffe8..42628a4b9d 100644
--- a/usr/src/cmd/lp/cmd/lpsched/Makefile
+++ b/usr/src/cmd/lp/cmd/lpsched/Makefile
@@ -22,8 +22,6 @@
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
# cmd/lp/cmd/lpsched/lpsched/Makefile
#
@@ -102,13 +100,13 @@ LPLIBS = \
SYSLIBS= -lcurses -lgen -lcurses -lnsl -ltsol -lsecdb -lbsm
-LDLIBS += $(LPLIBS) $(SYSLIBS)
+LDLIBS += $(LPLIBS) $(SYSLIBS) $(LDSTACKPROTECT)
POFILE= lp_cmd_lpsched.po
.KEEP_STATE:
-all: $(PROG)
+all: $(PROG)
$(PROG): $(OBJS) $(LPLIBS)
$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
diff --git a/usr/src/cmd/lp/model/Makefile b/usr/src/cmd/lp/model/Makefile
index 5da2ee6539..40840ecee0 100644
--- a/usr/src/cmd/lp/model/Makefile
+++ b/usr/src/cmd/lp/model/Makefile
@@ -19,8 +19,6 @@
# CDDL HEADER END
#
#
-# ident "%Z%%M% %I% %E% SMI"
-#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -62,8 +60,8 @@ ROOTMODELS = $(MODELS:%=$(ROOTLIBLPMODEL)/%)
CPPFLAGS = -I$(LPINC) $(CPPFLAGS.master)
# conditional assignments
-lp.tell := LDLIBS += $(LIBMSG) $(LIBLP)
-lp.set drain.output lp.cat := LDLIBS += $(LIBLP) -lcurses
+lp.tell := LDLIBS += $(LIBMSG) $(LIBLP) $(LDSTACKPROTECT)
+lp.set drain.output lp.cat := LDLIBS += $(LIBLP) -lcurses $(LDSTACKPROTECT)
lp.tsol_separator := LDLIBS += -ltsol
$(ROOTMISC) := FILEMODE = 0444
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,
diff --git a/usr/src/cmd/picl/plugins/common/piclevent/Makefile b/usr/src/cmd/picl/plugins/common/piclevent/Makefile
index 1b0ad54ea2..c1e4c4702a 100644
--- a/usr/src/cmd/picl/plugins/common/piclevent/Makefile
+++ b/usr/src/cmd/picl/plugins/common/piclevent/Makefile
@@ -36,7 +36,7 @@ include $(SRC)/cmd/picl/plugins/Makefile.com
MODULES = picl_slm.so
MOD_SRCS = picl_slm.c
MOD_OBJS = picl_slm.o
-MOD_LDLIBS = -L$(ROOT)/usr/lib -lsysevent -lnvpair -lc
+MOD_LDLIBS = -L$(ROOT)/usr/lib -lsysevent -lnvpair -lc $(LDSTACKPROTECT)
# sysevent SLM dirs
SYSEVENT = sysevent
diff --git a/usr/src/cmd/print/bsd-sysv-commands/Makefile b/usr/src/cmd/print/bsd-sysv-commands/Makefile
index f2b8c41230..2821e90db8 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/Makefile
+++ b/usr/src/cmd/print/bsd-sysv-commands/Makefile
@@ -60,7 +60,7 @@ CPPFLAGS += -I.
CPPFLAGS += -I../../../lib/print/libpapi-common/common
CPPFLAGS += -I$(ROOT)/usr/include
CPPFLAGS += -I../../lp/include
-LDLIBS += $(LIBLP) -lpapi -lc
+LDLIBS += $(LIBLP) $(LDSTACKPROTECT) -lpapi -lc
in.lpd:= CFLAGS += -DSOLARIS_PRIVATE_POST_0_9
in.lpd:= LDLIBS += -lnsl -lsocket
@@ -85,14 +85,14 @@ $(ROOTUSRUCB)/%: $(ROOTUSRUCB) %
$(ROOTLIBLPBIN)/%: %
$(INS.file)
-$(ROOTUCBSYMLINKS):
+$(ROOTUCBSYMLINKS):
$(RM) $@; $(SYMLINK) ../bin/$(@F) $@
# usr/lib links
ROOTUSRLIBSYMLINKS = $(SBINPROGS:%=$(ROOTLIB)/%)
$(ROOTLIB)/%: $(ROOTLIB) %
-$(ROOTUSRLIBSYMLINKS):
+$(ROOTUSRLIBSYMLINKS):
$(RM) $@; $(SYMLINK) ../sbin/$(@F) $@
.KEEP_STATE:
@@ -104,7 +104,7 @@ install: $(ROOTLIBLPPROGS) \
check: $(CHKMANIFEST)
clean:
- $(RM) $(OBJS)
+ $(RM) $(OBJS)
CLOBBERFILES += $(BINPROGS) $(SBINPROGS) $(LIBPRINTPROGS)
diff --git a/usr/src/cmd/rcm_daemon/Makefile.com b/usr/src/cmd/rcm_daemon/Makefile.com
index a11c03bc4b..8267af63fc 100644
--- a/usr/src/cmd/rcm_daemon/Makefile.com
+++ b/usr/src/cmd/rcm_daemon/Makefile.com
@@ -135,7 +135,7 @@ SUNW_ip_rcm.so := LDLIBS_MODULES += -linetutil -ldladm -lipmp -lipadm -lnvpair -
SUNW_ip_anon_rcm.so := LDLIBS_MODULES += -linetutil
SUNW_bridge_rcm.so := LDLIBS_MODULES += -ldladm -lnvpair
SUNW_mpxio_rcm.so := LDLIBS_MODULES += -ldevinfo
-LDLIBS_MODULES += -lrcm -lc
+LDLIBS_MODULES += -lrcm -lc $(LDSTACKPROTECT)
LDLIBS += -lrcm -lnvpair
diff --git a/usr/src/cmd/sgs/elfdump/common/corenote.c b/usr/src/cmd/sgs/elfdump/common/corenote.c
index a5ba4e31b8..7b768a0309 100644
--- a/usr/src/cmd/sgs/elfdump/common/corenote.c
+++ b/usr/src/cmd/sgs/elfdump/common/corenote.c
@@ -26,6 +26,7 @@
/*
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
* Copyright (c) 2018, Joyent, Inc.
+ * Copyright 2020 Oxide Computer Company
*/
#include <stdlib.h>
@@ -39,6 +40,8 @@
#include <_elfdump.h>
#include <struct_layout.h>
#include <conv.h>
+#include <ctype.h>
+#include <sys/sysmacros.h>
/*
@@ -94,7 +97,6 @@
print_strbuf(state, _title, &layout->_field)
-
/*
* Structure used to maintain state data for a core note, or a subregion
* (sub-struct) of a core note. These values would otherwise need to be
@@ -136,26 +138,59 @@ typedef void (* dump_func_t)(note_state_t *state, const char *title);
static const char *
safe_str(const char *str, size_t n)
{
- static char buf[512];
- char *s;
- size_t i;
+ static char buf[2048];
+ size_t i, used;
if (n == 0)
return (MSG_ORIG(MSG_STR_EMPTY));
- for (i = 0; i < n; i++)
+ /*
+ * If the string is terminated and doesn't need escaping, we can return
+ * it as is.
+ */
+ for (i = 0; i < n; i++) {
if (str[i] == '\0')
return (str);
- i = (n >= sizeof (buf)) ? (sizeof (buf) - 4) : (n - 1);
- (void) memcpy(buf, str, i);
- s = buf + i;
- if (n >= sizeof (buf)) {
- *s++ = '.';
- *s++ = '.';
- *s++ = '.';
+ if (!isascii(str[i]) || !isprint(str[i])) {
+ break;
+ }
}
- *s = '\0';
+
+ for (i = 0, used = 0; i < n; i++) {
+ if (str[i] == '\0') {
+ if (used + 1 > sizeof (buf))
+ break;
+ buf[used++] = str[i];
+ return (buf);
+ } else if (isascii(str[i]) && isprint(str[i])) {
+ if (used + 1 > sizeof (buf))
+ break;
+ buf[used++] = str[i];
+ } else {
+ size_t len = snprintf(NULL, 0, "\\x%02x", str[i]);
+ if (used + len > sizeof (buf))
+ break;
+ (void) snprintf(buf + used, sizeof (buf) - used,
+ "\\x%02x", str[i]);
+ used += len;
+ }
+ }
+
+ if (i == n && used < sizeof (buf)) {
+ buf[used] = '\0';
+ return (buf);
+ }
+
+ /*
+ * If we got here, we would have overflowed. Figure out where we need to
+ * start and truncate.
+ */
+ used = MIN(used, sizeof (buf) - 4);
+ buf[used++] = '.';
+ buf[used++] = '.';
+ buf[used++] = '.';
+ buf[used++] = '\0';
return (buf);
}
@@ -198,7 +233,7 @@ data_present(note_state_t *state, const sl_field_t *fdesc)
/*
* indent_enter/exit are used to start/end output for a subitem.
* On entry, a title is output, and the indentation level is raised
- * by one unit. On exit, the indentation level is restrored to its
+ * by one unit. On exit, the indentation level is restored to its
* previous value.
*/
static void
@@ -1759,6 +1794,40 @@ dump_asrset(note_state_t *state, const char *title)
indent_exit(state);
}
+static void
+dump_upanic(note_state_t *state, const char *title)
+{
+ const sl_prupanic_layout_t *layout = state->ns_arch->prupanic;
+ Conv_upanic_buf_t inv;
+ Word w;
+
+ indent_enter(state, title, &layout->pru_version);
+ w = extract_as_word(state, &layout->pru_version);
+ if (w != PRUPANIC_VERSION_1) {
+ PRINT_DEC(MSG_INTL(MSG_NOTE_BAD_UPANIC_VER), pru_version);
+ dump_hex_bytes(state->ns_data, state->ns_len, state->ns_indent,
+ 4, 3);
+ } else {
+ PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PRU_VERSION), pru_version);
+ w = extract_as_word(state, &layout->pru_flags);
+ print_str(state, MSG_ORIG(MSG_CNOTE_T_PRU_FLAGS),
+ conv_prupanic(w, 0, &inv));
+
+ if ((w & PRUPANIC_FLAG_MSG_VALID) != 0) {
+ /*
+ * We have a message that is _probably_ a text string,
+ * but the interface allows for arbitrary data. The only
+ * guarantee is that someone using this is probably up
+ * to no good. As a result, we basically try to print
+ * this as a string, but in the face of certain types of
+ * data, we hex escape it.
+ */
+ print_strbuf(state, MSG_ORIG(MSG_CNOTE_T_PRU_DATA),
+ &layout->pru_data);
+ }
+ }
+}
+
corenote_ret_t
corenote(Half mach, int do_swap, Word type,
const char *desc, Word descsz)
@@ -1928,6 +1997,11 @@ corenote(Half mach, int do_swap, Word type,
state.ns_vcol = 20;
dump_lwpname(&state, MSG_ORIG(MSG_CNOTE_DESC_PRLWPNAME_T));
return (CORENOTE_R_OK);
+
+ case NT_UPANIC:
+ state.ns_vcol = 23;
+ dump_upanic(&state, MSG_ORIG(MSG_CNOTE_DESC_PRUPANIC_T));
+ return (CORENOTE_R_OK);
}
return (CORENOTE_R_BADTYPE);
diff --git a/usr/src/cmd/sgs/elfdump/common/elfdump.msg b/usr/src/cmd/sgs/elfdump/common/elfdump.msg
index 20fe3ceb02..239a1f77ac 100644
--- a/usr/src/cmd/sgs/elfdump/common/elfdump.msg
+++ b/usr/src/cmd/sgs/elfdump/common/elfdump.msg
@@ -314,6 +314,7 @@
@ MSG_NOTE_BADCORETYPE "%s: unknown note type %#x\n"
@ MSG_NOTE_BAD_SECFLAGS_VER "unknown prsecflags_t version: "
+@ MSG_NOTE_BAD_UPANIC_VER "unknown prupanic_t version: "
@ _END_
@@ -472,6 +473,7 @@
@ MSG_CNOTE_DESC_PRFDINFO_T "desc: (prfdinfo_core_t)"
@ MSG_CNOTE_DESC_PRSECFLAGS_T "desc: (prsecflags_t)"
@ MSG_CNOTE_DESC_PRLWPNAME_T "desc: (prlwpname_t)"
+@ MSG_CNOTE_DESC_PRUPANIC_T "desc: (prupanic_t)"
@ MSG_CNOTE_FMT_LINE "%*s%-*s%s"
@ MSG_CNOTE_FMT_LINE_2UP "%*s%-*s%-*s%-*s%s"
@@ -646,6 +648,9 @@
@ MSG_CNOTE_T_PR_INO "pr_ino:"
@ MSG_CNOTE_T_PR_FILEFLAGS "pr_fileflags:"
@ MSG_CNOTE_T_PR_FDFLAGS "pr_fdflags:"
+@ MSG_CNOTE_T_PRU_VERSION "pru_version:"
+@ MSG_CNOTE_T_PRU_FLAGS "pru_flags:"
+@ MSG_CNOTE_T_PRU_DATA "pru_data:"
# Names of fake sections generated from program header data
diff --git a/usr/src/cmd/sgs/elfdump/common/gen_layout_obj.c b/usr/src/cmd/sgs/elfdump/common/gen_layout_obj.c
index 657ab05605..b307f40c72 100644
--- a/usr/src/cmd/sgs/elfdump/common/gen_layout_obj.c
+++ b/usr/src/cmd/sgs/elfdump/common/gen_layout_obj.c
@@ -61,3 +61,4 @@ struct utsname uts;
prfdinfo_core_t ptfd;
prsecflags_t psf;
prlwpname_t psn;
+prupanic_t pru;
diff --git a/usr/src/cmd/sgs/elfdump/common/gen_struct_layout.c b/usr/src/cmd/sgs/elfdump/common/gen_struct_layout.c
index 4f3d8b4dac..80e2d4964d 100644
--- a/usr/src/cmd/sgs/elfdump/common/gen_struct_layout.c
+++ b/usr/src/cmd/sgs/elfdump/common/gen_struct_layout.c
@@ -610,6 +610,16 @@ gen_prlwpname(void)
END;
}
+static void
+gen_prupanic(void)
+{
+ START(prupanic, prupanic_t);
+ SCALAR_FIELD(prupanic_t, pru_version, 0);
+ SCALAR_FIELD(prupanic_t, pru_flags, 0);
+ ARRAY_FIELD(prupanic_t, pru_data, 0);
+ END;
+}
+
/*ARGSUSED*/
int
main(int argc, char *argv[])
@@ -652,6 +662,7 @@ main(int argc, char *argv[])
gen_prfdinfo();
gen_prsecflags();
gen_prlwpname();
+ gen_prupanic();
/*
* Generate the full arch_layout description
@@ -681,6 +692,7 @@ main(int argc, char *argv[])
(void) printf(fmt, "prfdinfo");
(void) printf(fmt, "prsecflags");
(void) printf(fmt, "prlwpname");
+ (void) printf(fmt, "prupanic");
(void) printf("};\n");
/*
diff --git a/usr/src/cmd/sgs/elfdump/common/struct_layout.h b/usr/src/cmd/sgs/elfdump/common/struct_layout.h
index 7c43c33f99..6dde111468 100644
--- a/usr/src/cmd/sgs/elfdump/common/struct_layout.h
+++ b/usr/src/cmd/sgs/elfdump/common/struct_layout.h
@@ -543,6 +543,13 @@ typedef struct {
sl_field_t pr_lwpname;
} sl_prlwpname_layout_t;
+typedef struct {
+ sl_field_t sizeof_struct;
+ sl_field_t pru_version;
+ sl_field_t pru_flags;
+ sl_field_t pru_data;
+} sl_prupanic_layout_t;
+
/*
* This type collects all of the layout definitions for
* a given architecture.
@@ -570,6 +577,7 @@ typedef struct {
const sl_prfdinfo_layout_t *prfdinfo; /* prdinfo_t */
const sl_prsecflags_layout_t *prsecflags; /* prsecflags_t */
const sl_prlwpname_layout_t *prlwpname; /* prlwpname_t */
+ const sl_prupanic_layout_t *prupanic; /* prupanic_t */
} sl_arch_layout_t;
diff --git a/usr/src/cmd/sgs/elfdump/common/struct_layout_amd64.c b/usr/src/cmd/sgs/elfdump/common/struct_layout_amd64.c
index f040da7f3d..3107f42948 100644
--- a/usr/src/cmd/sgs/elfdump/common/struct_layout_amd64.c
+++ b/usr/src/cmd/sgs/elfdump/common/struct_layout_amd64.c
@@ -396,6 +396,14 @@ static const sl_prlwpname_layout_t prlwpname_layout = {
};
+static const sl_prupanic_layout_t prupanic_layout = {
+ { 0, 1032, 0, 0 }, /* sizeof (prupanic_t) */
+ { 0, 4, 0, 0 }, /* pru_version */
+ { 4, 4, 0, 0 }, /* pru_flags */
+ { 8, 1, 1024, 0 }, /* pru_data[] */
+};
+
+
static const sl_arch_layout_t layout_amd64 = {
@@ -421,6 +429,7 @@ static const sl_arch_layout_t layout_amd64 = {
&prfdinfo_layout,
&prsecflags_layout,
&prlwpname_layout,
+ &prupanic_layout,
};
diff --git a/usr/src/cmd/sgs/elfdump/common/struct_layout_i386.c b/usr/src/cmd/sgs/elfdump/common/struct_layout_i386.c
index 0e37cc5b95..cbdfee90d6 100644
--- a/usr/src/cmd/sgs/elfdump/common/struct_layout_i386.c
+++ b/usr/src/cmd/sgs/elfdump/common/struct_layout_i386.c
@@ -396,6 +396,14 @@ static const sl_prlwpname_layout_t prlwpname_layout = {
};
+static const sl_prupanic_layout_t prupanic_layout = {
+ { 0, 1032, 0, 0 }, /* sizeof (prupanic_t) */
+ { 0, 4, 0, 0 }, /* pru_version */
+ { 4, 4, 0, 0 }, /* pru_flags */
+ { 8, 1, 1024, 0 }, /* pru_data[] */
+};
+
+
static const sl_arch_layout_t layout_i386 = {
@@ -421,6 +429,7 @@ static const sl_arch_layout_t layout_i386 = {
&prfdinfo_layout,
&prsecflags_layout,
&prlwpname_layout,
+ &prupanic_layout,
};
diff --git a/usr/src/cmd/sgs/elfdump/common/struct_layout_sparc.c b/usr/src/cmd/sgs/elfdump/common/struct_layout_sparc.c
index 3e3abf9d2b..1033e887a3 100644
--- a/usr/src/cmd/sgs/elfdump/common/struct_layout_sparc.c
+++ b/usr/src/cmd/sgs/elfdump/common/struct_layout_sparc.c
@@ -396,6 +396,14 @@ static const sl_prlwpname_layout_t prlwpname_layout = {
};
+static const sl_prupanic_layout_t prupanic_layout = {
+ { 0, 1032, 0, 0 }, /* sizeof (prupanic_t) */
+ { 0, 4, 0, 0 }, /* pru_version */
+ { 4, 4, 0, 0 }, /* pru_flags */
+ { 8, 1, 1024, 0 }, /* pru_data[] */
+};
+
+
static const sl_arch_layout_t layout_sparc = {
@@ -421,6 +429,7 @@ static const sl_arch_layout_t layout_sparc = {
&prfdinfo_layout,
&prsecflags_layout,
&prlwpname_layout,
+ &prupanic_layout,
};
diff --git a/usr/src/cmd/sgs/elfdump/common/struct_layout_sparcv9.c b/usr/src/cmd/sgs/elfdump/common/struct_layout_sparcv9.c
index 7ca7b27b1d..b189261c3a 100644
--- a/usr/src/cmd/sgs/elfdump/common/struct_layout_sparcv9.c
+++ b/usr/src/cmd/sgs/elfdump/common/struct_layout_sparcv9.c
@@ -396,6 +396,14 @@ static const sl_prlwpname_layout_t prlwpname_layout = {
};
+static const sl_prupanic_layout_t prupanic_layout = {
+ { 0, 1032, 0, 0 }, /* sizeof (prupanic_t) */
+ { 0, 4, 0, 0 }, /* pru_version */
+ { 4, 4, 0, 0 }, /* pru_flags */
+ { 8, 1, 1024, 0 }, /* pru_data[] */
+};
+
+
static const sl_arch_layout_t layout_sparcv9 = {
@@ -421,6 +429,7 @@ static const sl_arch_layout_t layout_sparcv9 = {
&prfdinfo_layout,
&prsecflags_layout,
&prlwpname_layout,
+ &prupanic_layout,
};
diff --git a/usr/src/cmd/sgs/include/conv.h b/usr/src/cmd/sgs/include/conv.h
index 2c78d95b04..cff2530673 100644
--- a/usr/src/cmd/sgs/include/conv.h
+++ b/usr/src/cmd/sgs/include/conv.h
@@ -27,6 +27,7 @@
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
* Copyright (c) 2018, Joyent, Inc.
* Copyright 2016 RackTop Systems.
+ * Copyright 2020 Oxide Computer Company
*/
#ifndef _CONV_H
@@ -335,6 +336,13 @@ typedef union {
char buf[CONV_PRSECFLAGS_BUFSIZE];
} Conv_secflags_buf_t;
+/* conv_prupanic() */
+#define CONV_PRUPANIC_BUFSIZE 56
+typedef union {
+ Conv_inv_buf_t inv_buf;
+ char buf[CONV_PRUPANIC_BUFSIZE];
+} Conv_upanic_buf_t;
+
/* conv_cnote_sigset() */
#define CONV_CNOTE_SIGSET_BUFSIZE 639
typedef union {
@@ -350,7 +358,7 @@ typedef union {
} Conv_cnote_fltset_buf_t;
/* conv_cnote_sysset() */
-#define CONV_CNOTE_SYSSET_BUFSIZE 3195
+#define CONV_CNOTE_SYSSET_BUFSIZE 3227
typedef union {
Conv_inv_buf_t inv_buf;
char buf[CONV_CNOTE_SYSSET_BUFSIZE];
@@ -833,6 +841,8 @@ extern const char *conv_cnote_priv(int, Conv_fmt_flags_t,
Conv_inv_buf_t *);
extern const char *conv_prsecflags(secflagset_t, Conv_fmt_flags_t,
Conv_secflags_buf_t *);
+extern const char *conv_prupanic(uint32_t, Conv_fmt_flags_t,
+ Conv_upanic_buf_t *);
extern const char *conv_cnote_psetid(int, Conv_fmt_flags_t,
Conv_inv_buf_t *);
extern const char *conv_cnote_sa_flags(int, Conv_fmt_flags_t,
diff --git a/usr/src/cmd/sgs/libconv/Makefile.com b/usr/src/cmd/sgs/libconv/Makefile.com
index daffcfa01e..4cc0f5d8bc 100644
--- a/usr/src/cmd/sgs/libconv/Makefile.com
+++ b/usr/src/cmd/sgs/libconv/Makefile.com
@@ -120,3 +120,9 @@ MSGSRCS= $(COMOBJS:%.o=../common/%.c) \
SGSMSGTARG= $(BLTOBJS:%_msg.o=../common/%.msg)
CLEANFILES += $(BLTDATA) bld_vernote vernote.s
+
+#
+# Disable the stack protector due to issues with bootstrapping rtld. See
+# cmd/sgs/rtld/Makefile.com for more information.
+#
+STACKPROTECT = none
diff --git a/usr/src/cmd/sgs/libconv/common/corenote.c b/usr/src/cmd/sgs/libconv/common/corenote.c
index f86d534450..10900b0d27 100644
--- a/usr/src/cmd/sgs/libconv/common/corenote.c
+++ b/usr/src/cmd/sgs/libconv/common/corenote.c
@@ -26,6 +26,7 @@
/*
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
* Copyright (c) 2018 Joyent, Inc.
+ * Copyright 2020 Oxide Computer Company
*/
/*
@@ -59,9 +60,9 @@ conv_cnote_type(Word type, Conv_fmt_flags_t fmt_flags,
MSG_NT_PRPRIVINFO, MSG_NT_CONTENT,
MSG_NT_ZONENAME, MSG_NT_FDINFO,
MSG_NT_SPYMASTER, MSG_NT_SECFLAGS,
- MSG_NT_LWPNAME,
+ MSG_NT_LWPNAME, MSG_NT_UPANIC
};
-#if NT_NUM != NT_LWPNAME
+#if NT_NUM != NT_UPANIC
#error "NT_NUM has grown. Update core note types[]"
#endif
static const conv_ds_msg_t ds_types = {
@@ -255,8 +256,8 @@ conv_cnote_syscall(Word sysnum, Conv_fmt_flags_t fmt_flags,
MSG_SYS_MUNMAP, MSG_SYS_FPATHCONF,
MSG_SYS_VFORK, MSG_SYS_FCHDIR,
MSG_SYS_READV, MSG_SYS_WRITEV,
- MSG_SYS_123, MSG_SYS_124,
- MSG_SYS_125, MSG_SYS_126,
+ MSG_SYS_PREADV, MSG_SYS_PWRITEV,
+ MSG_SYS_UPANIC, MSG_SYS_GETRANDOM,
MSG_SYS_MMAPOBJ, MSG_SYS_SETRLIMIT,
MSG_SYS_GETRLIMIT, MSG_SYS_LCHOWN,
MSG_SYS_MEMCNTL, MSG_SYS_GETPMSG,
@@ -1956,10 +1957,10 @@ conv_cnote_fltset(uint32_t *maskarr, int n_mask,
MSG_SYS_FCHDIR_ALT_SIZE /* 120 */ + \
MSG_SYS_READV_ALT_SIZE /* 121 */ + \
MSG_SYS_WRITEV_ALT_SIZE /* 122 */ + \
- MSG_SYS_123_SIZE /* 123 (unused) */ + \
- MSG_SYS_124_SIZE /* 124 (unused) */ + \
- MSG_SYS_125_SIZE /* 125 (unused) */ + \
- MSG_SYS_126_SIZE /* 126 (unused) */ + \
+ MSG_SYS_PREADV_SIZE /* 123 */ + \
+ MSG_SYS_PWRITEV_SIZE /* 124 */ + \
+ MSG_SYS_UPANIC_SIZE /* 125 */ + \
+ MSG_SYS_GETRANDOM_SIZE /* 126 */ + \
MSG_SYS_MMAPOBJ_ALT_SIZE /* 127 */ + \
MSG_SYS_SETRLIMIT_ALT_SIZE /* 128 */ + \
\
@@ -2279,10 +2280,10 @@ conv_cnote_sysset(uint32_t *maskarr, int n_mask,
{ 0x00800000, MSG_SYS_FCHDIR_ALT },
{ 0x01000000, MSG_SYS_READV_ALT },
{ 0x02000000, MSG_SYS_WRITEV_ALT },
- { 0x04000000, MSG_SYS_123 },
- { 0x08000000, MSG_SYS_124 },
- { 0x10000000, MSG_SYS_125 },
- { 0x20000000, MSG_SYS_126 },
+ { 0x04000000, MSG_SYS_PREADV_ALT },
+ { 0x08000000, MSG_SYS_PWRITEV_ALT },
+ { 0x10000000, MSG_SYS_UPANIC_ALT },
+ { 0x20000000, MSG_SYS_GETRANDOM_ALT },
{ 0x40000000, MSG_SYS_MMAPOBJ_ALT },
{ 0x80000000, MSG_SYS_SETRLIMIT_ALT },
{ 0, 0 }
@@ -2642,3 +2643,54 @@ conv_prsecflags(secflagset_t flags, Conv_fmt_flags_t fmt_flags,
return ((const char *)secflags_buf->buf);
}
+
+
+#define UPANICFLGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
+ MSG_MSG_VALID_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
+ MSG_MSG_ERROR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
+ MSG_MSG_TRUNC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
+ CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
+
+/*
+ * Ensure that Conv_upanic_buf_t is large enough:
+ *
+ * UPANICFLGSZ is the real minimum size of the buffer required by
+ * conv_prsecflags(). However, Conv_upanic_buf_t uses CONV_PRUPANIC_BUFSIZE to
+ * set the buffer size. We do things this way because the definition of
+ * UPANICFLGSZ uses information that is not available in the environment of
+ * other programs that include the conv.h header file.
+ */
+#if (CONV_PRUPANIC_BUFSIZE != UPANICFLGSZ)
+#define REPORT_BUFSIZE UPANICFLGSZ
+#include "report_bufsize.h"
+#error "CONV_PRUPANIC_BUFSIZE does not match UPANICFLGSZ"
+#endif
+
+const char *
+conv_prupanic(uint32_t flags, Conv_fmt_flags_t fmt_flags,
+ Conv_upanic_buf_t *upanic_buf)
+{
+ /*
+ * Unfortunately, we cannot directly use the PRUPANIC_FLAG_* macros here
+ * because of the fact that this is also built natively and that would
+ * create an unresolvable flag day.
+ */
+ static Val_desc vda[] = {
+ { 0x01, MSG_MSG_VALID },
+ { 0x02, MSG_MSG_ERROR },
+ { 0x04, MSG_MSG_TRUNC },
+ { 0, 0 }
+ };
+ static CONV_EXPN_FIELD_ARG conv_arg = {
+ NULL, sizeof (upanic_buf->buf)
+ };
+
+ if (flags == 0)
+ return (MSG_ORIG(MSG_GBL_ZERO));
+
+ conv_arg.buf = upanic_buf->buf;
+ conv_arg.oflags = conv_arg.rflags = flags;
+ (void) conv_expn_field(&conv_arg, vda, fmt_flags);
+
+ return ((const char *)upanic_buf->buf);
+}
diff --git a/usr/src/cmd/sgs/libconv/common/corenote.msg b/usr/src/cmd/sgs/libconv/common/corenote.msg
index 78951cfb1d..7c75c5735e 100644
--- a/usr/src/cmd/sgs/libconv/common/corenote.msg
+++ b/usr/src/cmd/sgs/libconv/common/corenote.msg
@@ -25,6 +25,7 @@
#
# Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
# Copyright (c) 2018 Joyent, Inc.
+# Copyright 2020 Oxide Computer Company
#
@ MSG_NT_PRSTATUS "[ NT_PRSTATUS ]"
@@ -50,6 +51,7 @@
@ MSG_NT_SPYMASTER "[ NT_SPYMASTER ]"
@ MSG_NT_SECFLAGS "[ NT_SECFLAGS ]"
@ MSG_NT_LWPNAME "[ NT_LWPNAME ]"
+@ MSG_NT_UPANIC "[ NT_UPANIC ]"
@ MSG_AUXV_AF_SUN_SETUGID "AF_SUN_SETUGID"
@@ -291,6 +293,10 @@
@ MSG_FORBIDNULLMAP "FORBIDNULLMAP"
@ MSG_NOEXECSTACK "NOEXECSTACK"
+@ MSG_MSG_VALID "MSG_VALID"
+@ MSG_MSG_ERROR "MSG_ERROR"
+@ MSG_MSG_TRUNC "MSG_TRUNC"
+
@ MSG_PS_NONE "[ PS_NONE ]"
@ MSG_PS_QUERY "[ PS_QUERY ]"
@ MSG_PS_MYID "[ PS_MYID ]"
@@ -829,10 +835,14 @@
@ MSG_SYS_READV_ALT "readv"
@ MSG_SYS_WRITEV "[ writev ]" # 122
@ MSG_SYS_WRITEV_ALT "writev"
-@ MSG_SYS_123 "123" # 123(u)
-@ MSG_SYS_124 "124" # 124(u)
-@ MSG_SYS_125 "125" # 125(u)
-@ MSG_SYS_126 "126" # 126(u)
+@ MSG_SYS_PREADV "[ preadv ]" # 123
+@ MSG_SYS_PREADV_ALT "preadv"
+@ MSG_SYS_PWRITEV "[ pwritev ]" # 124
+@ MSG_SYS_PWRITEV_ALT "pwritev"
+@ MSG_SYS_UPANIC "[ upanic ]" # 125
+@ MSG_SYS_UPANIC_ALT "upanic"
+@ MSG_SYS_GETRANDOM "[ getrandom ]" # 126
+@ MSG_SYS_GETRANDOM_ALT "getrandom"
@ MSG_SYS_MMAPOBJ "[ mmapobj ]" # 127
@ MSG_SYS_MMAPOBJ_ALT "mmapobj"
@ MSG_SYS_SETRLIMIT "[ setrlimit ]" # 128
diff --git a/usr/src/cmd/sgs/rtld/Makefile.com b/usr/src/cmd/sgs/rtld/Makefile.com
index 853fd5066b..4b1a9a328d 100644
--- a/usr/src/cmd/sgs/rtld/Makefile.com
+++ b/usr/src/cmd/sgs/rtld/Makefile.com
@@ -154,3 +154,19 @@ SRCS= $(AVLOBJ:%.o=$(VAR_AVLDIR)/%.c) \
CLEANFILES += $(CRTS) $(BLTFILES)
CLOBBERFILES += $(RTLD)
+
+#
+# We cannot currently enable the stack protector for rtld as it runs
+# before libc initializes, which is where we always enable the stack
+# protector values. Because rtld is likely on an alternate link map and
+# links in the relevant portions of libc through libc_pic.a, there is
+# probably a path to enabling an rtld specific version of the stack
+# protector.
+#
+# As a result, this currently disables the stack protector in two
+# related targets which really could use it. These are libconv and libc.
+# Both of these end up building position-independent archive libraries
+# that are directly linked into rtld. This situation can and should be
+# improved.
+#
+STACKPROTECT = none
diff --git a/usr/src/cmd/truss/main.c b/usr/src/cmd/truss/main.c
index 23c2056314..9b7d7bac54 100644
--- a/usr/src/cmd/truss/main.c
+++ b/usr/src/cmd/truss/main.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2015, Joyent, Inc.
+ * Copyright 2020 Oxide Computer Company
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -59,7 +60,7 @@
*/
typedef struct proc_set {
pid_t pid;
- const char *lwps;
+ const char *lwps;
} proc_set_t;
/*
@@ -684,6 +685,7 @@ main(int argc, char *argv[])
praddset(&traceeven, SYS_open64);
praddset(&traceeven, SYS_vfork);
praddset(&traceeven, SYS_forksys);
+ praddset(&traceeven, SYS_upanic);
/* for I/O buffer dumps, force tracing of read()s and write()s */
if (!isemptyset(&readfd)) {
@@ -723,8 +725,10 @@ main(int argc, char *argv[])
/* special case -- sysexit never reached */
(void) Psysentry(Proc, SYS_exit, TRUE);
(void) Psysentry(Proc, SYS_lwp_exit, TRUE);
+ (void) Psysentry(Proc, SYS_upanic, TRUE);
(void) Psysexit(Proc, SYS_exit, FALSE);
(void) Psysexit(Proc, SYS_lwp_exit, FALSE);
+ (void) Psysexit(Proc, SYS_upanic, FALSE);
Psetsignal(Proc, &signals); /* trace these signals */
Psetfault(Proc, &faults); /* trace these faults */
@@ -1090,6 +1094,7 @@ worker_thread(void *arg)
switch (what) {
case SYS_exit: /* exit() */
case SYS_lwp_exit: /* lwp_exit() */
+ case SYS_upanic: /* upanic() */
case SYS_context: /* [get|set]context() */
if (dotrace && cflag &&
prismember(&trace, what)) {
@@ -2692,7 +2697,7 @@ letgo(private_t *pri)
*/
int
is_empty(const uint32_t *sp, /* pointer to set (array of int32's) */
- size_t n) /* number of int32's in set */
+ size_t n) /* number of int32's in set */
{
if (n) {
do {
diff --git a/usr/src/cmd/truss/systable.c b/usr/src/cmd/truss/systable.c
index 9e4d1780f4..ecc8c66b3a 100644
--- a/usr/src/cmd/truss/systable.c
+++ b/usr/src/cmd/truss/systable.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
+ * Copyright 2020 Oxide Computer Company
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -347,7 +348,7 @@ const struct systable systable[] = {
{"writev", 3, DEC, NOV, DEC, HEX, DEC}, /* 122 */
{"preadv", 4, DEC, NOV, DEC, HEX, DEC, DEC}, /* 123 */
{"pwritev", 4, DEC, NOV, DEC, HEX, DEC, DEC}, /* 124 */
-{ NULL, 8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
+{"upanic", 2, DEC, NOV, HEX, DEC}, /* 125 */
{"getrandom", 3, DEC, NOV, IOB, UNS, GRF}, /* 126 */
{"mmapobj", 5, DEC, NOV, DEC, MOB, HEX, HEX, HEX}, /* 127 */
{"setrlimit", 2, DEC, NOV, RLM, HEX}, /* 128 */