summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2005-12-23 11:58:42 +0000
committerphk <phk@FreeBSD.org>2005-12-23 11:58:42 +0000
commit213233d76c0df33000bc2595f9f352f7d3041680 (patch)
treedbed01ddde32dd5ebd12a08f5978e69705e0891e /sys/kern
parent80e1c5a55d041cc755e763279ed18653841b626d (diff)
downloadFreeBSD-src-213233d76c0df33000bc2595f9f352f7d3041680.zip
FreeBSD-src-213233d76c0df33000bc2595f9f352f7d3041680.tar.gz
Regenerate sysent with new abort2 system call.
Implement abort2(const char *reason, int narg, void **args); Submitted by: "Wojciech A. Koszek" <dunstan@freebsd.czest.pl>
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/init_sysent.c3
-rw-r--r--sys/kern/kern_exit.c83
-rw-r--r--sys/kern/syscalls.c3
3 files changed, 87 insertions, 2 deletions
diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c
index 0bf661e..6d5cf40 100644
--- a/sys/kern/init_sysent.c
+++ b/sys/kern/init_sysent.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.205 2005/11/27 01:13:00 davidxu Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.206 2005/12/23 11:54:11 phk Exp
*/
#include "opt_compat.h"
@@ -492,4 +492,5 @@ struct sysent sysent[] = {
{ SYF_MPSAFE | AS(mq_timedsend_args), (sy_call_t *)lkmressys, AUE_NULL }, /* 460 = mq_timedsend */
{ SYF_MPSAFE | AS(mq_notify_args), (sy_call_t *)lkmressys, AUE_NULL }, /* 461 = mq_notify */
{ SYF_MPSAFE | AS(mq_unlink_args), (sy_call_t *)lkmressys, AUE_NULL }, /* 462 = mq_unlink */
+ { SYF_MPSAFE | AS(abort2_args), (sy_call_t *)abort2, AUE_NULL }, /* 463 = abort2 */
};
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 024a1f7..56f800f 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -56,10 +56,12 @@ __FBSDID("$FreeBSD$");
#include <sys/vmmeter.h>
#include <sys/vnode.h>
#include <sys/resourcevar.h>
+#include <sys/sbuf.h>
#include <sys/signalvar.h>
#include <sys/sched.h>
#include <sys/sx.h>
#include <sys/syscallsubr.h>
+#include <sys/syslog.h>
#include <sys/ptrace.h>
#include <sys/acct.h> /* for acct_process() function prototype */
#include <sys/filedesc.h>
@@ -553,6 +555,87 @@ retry:
thread_exit();
}
+
+#ifndef _SYS_SYSPROTO_H_
+struct abort2_args {
+ char *why;
+ int nargs;
+ void **args;
+};
+#endif
+
+/*
+ * MPSAFE.
+ */
+int
+abort2(struct thread *td, struct abort2_args *uap)
+{
+ struct proc *p = td->td_proc;
+ struct sbuf *sb;
+ void *uargs[16];
+ int error, i, sig;
+
+ error = 0; /* satisfy compiler */
+
+ /*
+ * Do it right now so we can log either proper call of abort2(), or
+ * note, that invalid argument was passed. 512 is big enough to
+ * handle 16 arguments' descriptions with additional comments.
+ */
+ sb = sbuf_new(NULL, NULL, 512, SBUF_FIXEDLEN);
+ sbuf_clear(sb);
+ sbuf_printf(sb, "%s(pid %d uid %d) aborted: ",
+ p->p_comm, p->p_pid, td->td_ucred->cr_uid);
+ /*
+ * Since we can't return from abort2(), send SIGKILL in cases, where
+ * abort2() was called improperly
+ */
+ sig = SIGKILL;
+ /* Prevent from DoSes from user-space. */
+ if (uap->nargs < 0 || uap->nargs > 16)
+ goto out;
+ if (uap->args == NULL)
+ goto out;
+ error = copyin(uap->args, uargs, uap->nargs * sizeof(void *));
+ if (error != 0)
+ goto out;
+ /*
+ * Limit size of 'reason' string to 128. Will fit even when
+ * maximal number of arguments was chosen to be logged.
+ */
+ if (uap->why != NULL) {
+ error = sbuf_copyin(sb, uap->why, 128);
+ if (error < 0)
+ goto out;
+ } else {
+ sbuf_printf(sb, "(null)");
+ }
+ if (uap->nargs) {
+ sbuf_printf(sb, "(");
+ for (i = 0;i < uap->nargs; i++)
+ sbuf_printf(sb, "%s%p", i == 0 ? "" : ", ", uargs[i]);
+ sbuf_printf(sb, ")");
+ }
+ /*
+ * Final stage: arguments were proper, string has been
+ * successfully copied from userspace, and copying pointers
+ * from user-space succeed.
+ */
+ sig = SIGABRT;
+out:
+ if (sig == SIGKILL) {
+ sbuf_trim(sb);
+ sbuf_printf(sb, " (Reason text inaccessible)");
+ }
+ sbuf_cat(sb, "\n");
+ sbuf_finish(sb);
+ log(LOG_INFO, "%s", sbuf_data(sb));
+ sbuf_delete(sb);
+ exit1(td, W_EXITCODE(0, sig));
+ return (0);
+}
+
+
#ifdef COMPAT_43
/*
* The dirty work is handled by kern_wait().
diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c
index dc9e172..33f4c45 100644
--- a/sys/kern/syscalls.c
+++ b/sys/kern/syscalls.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.205 2005/11/27 01:13:00 davidxu Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.206 2005/12/23 11:54:11 phk Exp
*/
const char *syscallnames[] = {
@@ -470,4 +470,5 @@ const char *syscallnames[] = {
"mq_timedsend", /* 460 = mq_timedsend */
"mq_notify", /* 461 = mq_notify */
"mq_unlink", /* 462 = mq_unlink */
+ "abort2", /* 463 = abort2 */
};
OpenPOWER on IntegriCloud