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>
This commit is contained in:
phk 2005-12-23 11:58:42 +00:00
parent 80e1c5a55d
commit 213233d76c
10 changed files with 130 additions and 12 deletions

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.57 2005/10/26 22:19:51 peter Exp
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.60 2005/12/23 11:56:39 phk Exp
*/
#ifndef _FREEBSD32_SYSPROTO_H_
@ -272,6 +272,11 @@ struct freebsd32_swapcontext_args {
char oucp_l_[PADL_(struct freebsd32_ucontext *)]; struct freebsd32_ucontext * oucp; char oucp_r_[PADR_(struct freebsd32_ucontext *)];
char ucp_l_[PADL_(const struct freebsd32_ucontext *)]; const struct freebsd32_ucontext * ucp; char ucp_r_[PADR_(const struct freebsd32_ucontext *)];
};
struct abort2_args {
char why_l_[PADL_(const char *)]; const char * why; char why_r_[PADR_(const char *)];
char nargs_l_[PADL_(int)]; int nargs; char nargs_r_[PADR_(int)];
char args_l_[PADL_(void **)]; void ** args; char args_r_[PADR_(void **)];
};
int freebsd32_wait4(struct thread *, struct freebsd32_wait4_args *);
int freebsd32_recvmsg(struct thread *, struct freebsd32_recvmsg_args *);
int freebsd32_sendmsg(struct thread *, struct freebsd32_sendmsg_args *);
@ -316,6 +321,7 @@ int freebsd32_sigreturn(struct thread *, struct freebsd32_sigreturn_args *);
int freebsd32_getcontext(struct thread *, struct freebsd32_getcontext_args *);
int freebsd32_setcontext(struct thread *, struct freebsd32_setcontext_args *);
int freebsd32_swapcontext(struct thread *, struct freebsd32_swapcontext_args *);
int abort2(struct thread *, struct abort2_args *);
#ifdef COMPAT_43

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.57 2005/10/26 22:19:51 peter Exp
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.60 2005/12/23 11:56:39 phk Exp
*/
#define FREEBSD32_SYS_syscall 0
@ -310,4 +310,5 @@
#define FREEBSD32_SYS_thr_suspend 442
#define FREEBSD32_SYS_thr_wake 443
#define FREEBSD32_SYS_kldunloadf 444
#define FREEBSD32_SYS_MAXSYSCALL 455
#define FREEBSD32_SYS_abort2 463
#define FREEBSD32_SYS_MAXSYSCALL 464

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.57 2005/10/26 22:19:51 peter Exp
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.60 2005/12/23 11:56:39 phk Exp
*/
const char *freebsd32_syscallnames[] = {
@ -462,4 +462,13 @@ const char *freebsd32_syscallnames[] = {
"#452", /* 452 = setaudit_addr */
"#453", /* 453 = auditctl */
"#454", /* 454 = _umtx_op */
"#455", /* 455 = thr_new */
"#456", /* 456 = sigqueue */
"#457", /* 457 = mq_open */
"#458", /* 458 = mq_setattr */
"#459", /* 459 = mq_timedreceive */
"#460", /* 460 = mq_timedsend */
"#461", /* 461 = mq_notify */
"#462", /* 462 = mq_unlink */
"abort2", /* 463 = abort2 */
};

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.57 2005/10/26 22:19:51 peter Exp
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.60 2005/12/23 11:56:39 phk Exp
*/
#include "opt_compat.h"
@ -487,4 +487,13 @@ struct sysent freebsd32_sysent[] = {
{ 0, (sy_call_t *)nosys, AUE_NULL }, /* 452 = setaudit_addr */
{ 0, (sy_call_t *)nosys, AUE_NULL }, /* 453 = auditctl */
{ 0, (sy_call_t *)nosys, AUE_NULL }, /* 454 = _umtx_op */
{ 0, (sy_call_t *)nosys, AUE_NULL }, /* 455 = thr_new */
{ 0, (sy_call_t *)nosys, AUE_NULL }, /* 456 = sigqueue */
{ 0, (sy_call_t *)nosys, AUE_NULL }, /* 457 = mq_open */
{ 0, (sy_call_t *)nosys, AUE_NULL }, /* 458 = mq_setattr */
{ 0, (sy_call_t *)nosys, AUE_NULL }, /* 459 = mq_timedreceive */
{ 0, (sy_call_t *)nosys, AUE_NULL }, /* 460 = mq_timedsend */
{ 0, (sy_call_t *)nosys, AUE_NULL }, /* 461 = mq_notify */
{ 0, (sy_call_t *)nosys, AUE_NULL }, /* 462 = mq_unlink */
{ SYF_MPSAFE | AS(abort2_args), (sy_call_t *)abort2, AUE_NULL }, /* 463 = abort2 */
};

View File

@ -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 */
};

View File

@ -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().

View File

@ -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 */
};

View File

@ -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
*/
#define SYS_syscall 0
@ -386,4 +386,5 @@
#define SYS_mq_timedsend 460
#define SYS_mq_notify 461
#define SYS_mq_unlink 462
#define SYS_MAXSYSCALL 463
#define SYS_abort2 463
#define SYS_MAXSYSCALL 464

View File

@ -1,7 +1,7 @@
# FreeBSD system call names.
# 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
MIASM = \
syscall.o \
exit.o \
@ -327,4 +327,5 @@ MIASM = \
mq_timedreceive.o \
mq_timedsend.o \
mq_notify.o \
mq_unlink.o
mq_unlink.o \
abort2.o

View File

@ -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
*/
#ifndef _SYS_SYSPROTO_H_
@ -1435,6 +1435,11 @@ struct mq_notify_args {
struct mq_unlink_args {
char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
};
struct abort2_args {
char why_l_[PADL_(const char *)]; const char * why; char why_r_[PADR_(const char *)];
char nargs_l_[PADL_(int)]; int nargs; char nargs_r_[PADR_(int)];
char args_l_[PADL_(void **)]; void ** args; char args_r_[PADR_(void **)];
};
int nosys(struct thread *, struct nosys_args *);
void sys_exit(struct thread *, struct sys_exit_args *);
int fork(struct thread *, struct fork_args *);
@ -1759,6 +1764,7 @@ int mq_timedreceive(struct thread *, struct mq_timedreceive_args *);
int mq_timedsend(struct thread *, struct mq_timedsend_args *);
int mq_notify(struct thread *, struct mq_notify_args *);
int mq_unlink(struct thread *, struct mq_unlink_args *);
int abort2(struct thread *, struct abort2_args *);
#ifdef COMPAT_43