summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@fingolfin.org>2020-10-22 15:56:51 -0700
committerRobert Mustacchi <rm@fingolfin.org>2020-11-17 08:52:10 -0800
commit350ffdd54baf880f440ddf9697666e283894ded1 (patch)
tree938d79d2ad158d809fa15d80774e56b68056a434 /usr/src/lib
parent7fdea60d55a95f0e46066fd021c4ef1b1321bafc (diff)
downloadillumos-joyent-350ffdd54baf880f440ddf9697666e283894ded1.tar.gz
13273 want upanic(2)
Reviewed by: C Fraire <cfraire@me.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Gordon Ross <gordon.w.ross@gmail.com>
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/libc/amd64/Makefile1
-rw-r--r--usr/src/lib/libc/i386/Makefile.com1
-rw-r--r--usr/src/lib/libc/port/mapfile-vers5
-rw-r--r--usr/src/lib/libc/port/sys/upanic.c23
-rw-r--r--usr/src/lib/libc/port/threads/assfail.c32
-rw-r--r--usr/src/lib/libc/sparc/Makefile.com1
-rw-r--r--usr/src/lib/libc/sparcv9/Makefile.com1
-rw-r--r--usr/src/lib/libproc/common/Pcontrol.c2
-rw-r--r--usr/src/lib/libproc/common/Pcontrol.h1
-rw-r--r--usr/src/lib/libproc/common/Pcore.c65
-rw-r--r--usr/src/lib/libproc/common/libproc.h6
-rw-r--r--usr/src/lib/libproc/common/mapfile-vers2
-rw-r--r--usr/src/lib/libproc/common/proc_names.c3
13 files changed, 119 insertions, 24 deletions
diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile
index a8ca8b1234..7ef34a268d 100644
--- a/usr/src/lib/libc/amd64/Makefile
+++ b/usr/src/lib/libc/amd64/Makefile
@@ -279,6 +279,7 @@ COMSYSOBJS= \
ulimit.o \
umask.o \
umount2.o \
+ upanic.o \
utssys.o \
uucopy.o \
vhangup.o \
diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com
index d3e2c51360..e9e9479ac9 100644
--- a/usr/src/lib/libc/i386/Makefile.com
+++ b/usr/src/lib/libc/i386/Makefile.com
@@ -306,6 +306,7 @@ COMSYSOBJS= \
ulimit.o \
umask.o \
umount2.o \
+ upanic.o \
utssys.o \
uucopy.o \
vhangup.o \
diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers
index 0be36d5e6b..6a85e0d37e 100644
--- a/usr/src/lib/libc/port/mapfile-vers
+++ b/usr/src/lib/libc/port/mapfile-vers
@@ -78,6 +78,11 @@ $if _x86 && _ELF64
$add amd64
$endif
+SYMBOL_VERSION ILLUMOS_0.36 {
+ protected:
+ upanic;
+} ILLUMOS_0.35;
+
SYMBOL_VERSION ILLUMOS_0.35 {
protected:
qsort_r;
diff --git a/usr/src/lib/libc/port/sys/upanic.c b/usr/src/lib/libc/port/sys/upanic.c
new file mode 100644
index 0000000000..2edfe4c4ff
--- /dev/null
+++ b/usr/src/lib/libc/port/sys/upanic.c
@@ -0,0 +1,23 @@
+/*
+ * 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 2020 Oxide Computer Company
+ */
+
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+void
+upanic(const void *buf, size_t len)
+{
+ (void) syscall(SYS_upanic, buf, len);
+}
diff --git a/usr/src/lib/libc/port/threads/assfail.c b/usr/src/lib/libc/port/threads/assfail.c
index 1c032d8ea7..4af2fc5664 100644
--- a/usr/src/lib/libc/port/threads/assfail.c
+++ b/usr/src/lib/libc/port/threads/assfail.c
@@ -26,10 +26,12 @@
/*
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright 2015 Joyent, Inc.
+ * Copyright 2020 Oxide Computer Company
*/
#include "lint.h"
#include "thr_uberdata.h"
+#include <upanic.h>
const char *panicstr;
ulwp_t *panic_thread;
@@ -60,35 +62,19 @@ grab_assert_lock()
}
static void
-Abort(const char *msg)
+Abort(const char *msg, size_t buflen)
{
ulwp_t *self;
struct sigaction act;
sigset_t sigmask;
- lwpid_t lwpid;
/* to help with core file debugging */
panicstr = msg;
if ((self = __curthread()) != NULL) {
panic_thread = self;
- lwpid = self->ul_lwpid;
- } else {
- lwpid = _lwp_self();
}
- /* set SIGABRT signal handler to SIG_DFL w/o grabbing any locks */
- (void) memset(&act, 0, sizeof (act));
- act.sa_sigaction = SIG_DFL;
- (void) __sigaction(SIGABRT, &act, NULL);
-
- /* delete SIGABRT from the signal mask */
- (void) sigemptyset(&sigmask);
- (void) sigaddset(&sigmask, SIGABRT);
- (void) __lwp_sigmask(SIG_UNBLOCK, &sigmask);
-
- (void) _lwp_kill(lwpid, SIGABRT); /* never returns */
- (void) kill(getpid(), SIGABRT); /* if it does, try harder */
- _exit(127);
+ upanic(msg, buflen);
}
/*
@@ -117,7 +103,7 @@ common_panic(const char *head, const char *why)
if (msg[len1 - 1] != '\n')
msg[len1++] = '\n';
(void) __write(2, msg, len1);
- Abort(msg);
+ Abort(msg, sizeof (msg));
}
void
@@ -246,7 +232,7 @@ lock_error(const mutex_t *mp, const char *who, void *cv, const char *msg)
(void) strcat(buf, "\n\n");
(void) __write(2, buf, strlen(buf));
if (udp->uberflags.uf_thread_error_detection >= 2)
- Abort(buf);
+ Abort(buf, sizeof (buf));
assert_thread = NULL;
(void) _lwp_mutex_unlock(&assert_lock);
if (self != NULL)
@@ -335,7 +321,7 @@ rwlock_error(const rwlock_t *rp, const char *who, const char *msg)
(void) strcat(buf, "\n\n");
(void) __write(2, buf, strlen(buf));
if (udp->uberflags.uf_thread_error_detection >= 2)
- Abort(buf);
+ Abort(buf, sizeof (buf));
assert_thread = NULL;
(void) _lwp_mutex_unlock(&assert_lock);
if (self != NULL)
@@ -383,7 +369,7 @@ thread_error(const char *msg)
(void) strcat(buf, "\n\n");
(void) __write(2, buf, strlen(buf));
if (udp->uberflags.uf_thread_error_detection >= 2)
- Abort(buf);
+ Abort(buf, sizeof (buf));
assert_thread = NULL;
(void) _lwp_mutex_unlock(&assert_lock);
if (self != NULL)
@@ -455,7 +441,7 @@ __assfail(const char *assertion, const char *filename, int line_num)
* if (self != NULL)
* exit_critical(self);
*/
- Abort(buf);
+ Abort(buf, sizeof (buf));
}
/*
diff --git a/usr/src/lib/libc/sparc/Makefile.com b/usr/src/lib/libc/sparc/Makefile.com
index 8ecec57516..7308fc64f6 100644
--- a/usr/src/lib/libc/sparc/Makefile.com
+++ b/usr/src/lib/libc/sparc/Makefile.com
@@ -322,6 +322,7 @@ COMSYSOBJS= \
ulimit.o \
umask.o \
umount2.o \
+ upanic.o \
utssys.o \
uucopy.o \
vhangup.o \
diff --git a/usr/src/lib/libc/sparcv9/Makefile.com b/usr/src/lib/libc/sparcv9/Makefile.com
index 7036b2e20d..9b7ff53999 100644
--- a/usr/src/lib/libc/sparcv9/Makefile.com
+++ b/usr/src/lib/libc/sparcv9/Makefile.com
@@ -304,6 +304,7 @@ COMSYSOBJS= \
ulimit.o \
umask.o \
umount2.o \
+ upanic.o \
utssys.o \
uucopy.o \
vhangup.o \
diff --git a/usr/src/lib/libproc/common/Pcontrol.c b/usr/src/lib/libproc/common/Pcontrol.c
index 5a135aef17..d9e3c8b9ea 100644
--- a/usr/src/lib/libproc/common/Pcontrol.c
+++ b/usr/src/lib/libproc/common/Pcontrol.c
@@ -1312,6 +1312,8 @@ Psecflags(struct ps_prochandle *P, prsecflags_t **psf)
if ((ret = P->ops.pop_secflags(P, psf, P->data)) == 0) {
if ((*psf)->pr_version != PRSECFLAGS_VERSION_1) {
+ free(*psf);
+ *psf = NULL;
errno = EINVAL;
return (-1);
}
diff --git a/usr/src/lib/libproc/common/Pcontrol.h b/usr/src/lib/libproc/common/Pcontrol.h
index 0eed5042a4..4aa4091d1f 100644
--- a/usr/src/lib/libproc/common/Pcontrol.h
+++ b/usr/src/lib/libproc/common/Pcontrol.h
@@ -171,6 +171,7 @@ typedef struct core_info { /* information specific to core files */
priv_impl_info_t *core_ppii; /* NOTE entry for core_privinfo */
char *core_zonename; /* zone name from core file */
prsecflags_t *core_secflags; /* secflags from core file */
+ prupanic_t *core_upanic; /* upanic from core file */
#if defined(__i386) || defined(__amd64)
struct ssd *core_ldt; /* LDT entries from core file */
uint_t core_nldt; /* number of LDT entries in core file */
diff --git a/usr/src/lib/libproc/common/Pcore.c b/usr/src/lib/libproc/common/Pcore.c
index cd539876b1..39424fad67 100644
--- a/usr/src/lib/libproc/common/Pcore.c
+++ b/usr/src/lib/libproc/common/Pcore.c
@@ -245,6 +245,8 @@ Pfini_core(struct ps_prochandle *P, void *data)
free(core->core_zonename);
if (core->core_secflags != NULL)
free(core->core_secflags);
+ if (core->core_upanic != NULL)
+ free(core->core_upanic);
#ifdef __x86
if (core->core_ldt != NULL)
free(core->core_ldt);
@@ -1201,6 +1203,34 @@ err:
return (-1);
}
+static int
+note_upanic(struct ps_prochandle *P, size_t nbytes)
+{
+ core_info_t *core = P->data;
+ prupanic_t *pru;
+
+ if (core->core_upanic != NULL)
+ return (0);
+
+ if (sizeof (*pru) != nbytes) {
+ dprintf("Pgrab_core: NT_UPANIC changed size."
+ " Need to handle a version change?\n");
+ return (-1);
+ }
+
+ if (nbytes != 0 && ((pru = malloc(nbytes)) != NULL)) {
+ if (read(P->asfd, pru, nbytes) != nbytes) {
+ dprintf("Pgrab_core: failed to read NT_UPANIC\n");
+ free(pru);
+ return (-1);
+ }
+
+ core->core_upanic = pru;
+ }
+
+ return (0);
+}
+
/*ARGSUSED*/
static int
note_notsup(struct ps_prochandle *P, size_t nbytes)
@@ -1266,6 +1296,7 @@ static int (*nhdlrs[])(struct ps_prochandle *, size_t) = {
note_spymaster, /* 23 NT_SPYMASTER */
note_secflags, /* 24 NT_SECFLAGS */
note_lwpname, /* 25 NT_LWPNAME */
+ note_upanic /* 26 NT_UPANIC */
};
static void
@@ -2880,3 +2911,37 @@ Pgrab_core(const char *core, const char *aout, int gflag, int *perr)
return (NULL);
}
+
+int
+Pupanic(struct ps_prochandle *P, prupanic_t **pru)
+{
+ core_info_t *core;
+
+ if (P->state != PS_DEAD) {
+ errno = ENODATA;
+ return (-1);
+ }
+
+ core = P->data;
+ if (core->core_upanic == NULL) {
+ errno = ENOENT;
+ return (-1);
+ }
+
+ if (core->core_upanic->pru_version != PRUPANIC_VERSION_1) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ if ((*pru = calloc(1, sizeof (prupanic_t))) == NULL)
+ return (-1);
+ (void) memcpy(*pru, core->core_upanic, sizeof (prupanic_t));
+
+ return (0);
+}
+
+void
+Pupanic_free(prupanic_t *pru)
+{
+ free(pru);
+}
diff --git a/usr/src/lib/libproc/common/libproc.h b/usr/src/lib/libproc/common/libproc.h
index cdf789a621..a73f8af647 100644
--- a/usr/src/lib/libproc/common/libproc.h
+++ b/usr/src/lib/libproc/common/libproc.h
@@ -792,6 +792,12 @@ extern int proc_finistdio(void);
typedef int proc_fdinfo_f(void *, const prfdinfo_t *);
extern int Pfdinfo_iter(struct ps_prochandle *, proc_fdinfo_f *, void *);
+/*
+ * NT_UPANIC information.
+ */
+extern int Pupanic(struct ps_prochandle *, prupanic_t **);
+extern void Pupanic_free(prupanic_t *);
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/lib/libproc/common/mapfile-vers b/usr/src/lib/libproc/common/mapfile-vers
index 1da5918393..61934de499 100644
--- a/usr/src/lib/libproc/common/mapfile-vers
+++ b/usr/src/lib/libproc/common/mapfile-vers
@@ -307,6 +307,8 @@ SYMBOL_VERSION SUNWprivate_1.1 {
Punsetflags;
Pupdate_maps;
Pupdate_syms;
+ Pupanic;
+ Pupanic_free;
Pwait;
Pwrite;
Pxcreate;
diff --git a/usr/src/lib/libproc/common/proc_names.c b/usr/src/lib/libproc/common/proc_names.c
index 314b01fbcd..65332da273 100644
--- a/usr/src/lib/libproc/common/proc_names.c
+++ b/usr/src/lib/libproc/common/proc_names.c
@@ -24,6 +24,7 @@
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
* Copyright 2019, Carlos Neira <cneirabustos@gmail.com>
* Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
+ * Copyright 2020 Oxide Computer Company
*/
#include <stdio.h>
@@ -241,7 +242,7 @@ static const char *const systable[] = {
"writev", /* 122 */
"preadv", /* 123 */
"pwritev", /* 124 */
- NULL, /* 125 */
+ "upanic", /* 125 */
"getrandom", /* 126 */
"mmapobj", /* 127 */
"setrlimit", /* 128 */