aboutsummaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>1996-03-02 19:38:20 +0000
committerPeter Wemm <peter@FreeBSD.org>1996-03-02 19:38:20 +0000
commitd66a506616078adf4d266a309f979ffd95fe634f (patch)
tree83b4d342a731e2a76c19f214d574f24753abe420 /sys/kern
parent9a074e93b595e10edfd4c6fd6bdacc61879fe381 (diff)
downloadsrc-d66a506616078adf4d266a309f979ffd95fe634f.tar.gz
src-d66a506616078adf4d266a309f979ffd95fe634f.zip
Notes
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/imgact_aout.c4
-rw-r--r--sys/kern/init_sysent.c11
-rw-r--r--sys/kern/init_sysvec.c29
-rw-r--r--sys/kern/kern_exec.c14
-rw-r--r--sys/kern/kern_sig.c34
-rw-r--r--sys/kern/makesyscalls.sh16
-rw-r--r--sys/kern/subr_trap.c137
7 files changed, 85 insertions, 160 deletions
diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c
index 2bfc18828c23..d183a22aab50 100644
--- a/sys/kern/imgact_aout.c
+++ b/sys/kern/imgact_aout.c
@@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: imgact_aout.c,v 1.21 1995/12/15 02:57:40 peter Exp $
+ * $Id: imgact_aout.c,v 1.22 1996/01/19 03:57:54 dyson Exp $
*/
#include <sys/param.h>
@@ -62,7 +62,6 @@ exec_aout_imgact(imgp)
unsigned long bss_size;
int error;
-#if defined(COMPAT_LINUX) || defined(LINUX)
/*
* Linux and *BSD binaries look very much alike,
* only the machine id is different:
@@ -71,7 +70,6 @@ exec_aout_imgact(imgp)
if (((a_out->a_magic >> 16) & 0xff) != 0x86 &&
((a_out->a_magic >> 16) & 0xff) != 0)
return -1;
-#endif /* COMPAT_LINUX || defined(LINUX) */
/*
* Set file/virtual offset based on a.out variant.
diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c
index ba630a758aba..77e5a30ff388 100644
--- a/sys/kern/init_sysent.c
+++ b/sys/kern/init_sysent.c
@@ -287,14 +287,3 @@ struct sysent sysent[] = {
{ 3, (sy_call_t *)minherit }, /* 250 = minherit */
{ 1, (sy_call_t *)rfork }, /* 251 = rfork */
};
-
-struct sysentvec aout_sysvec = {
- sizeof (sysent) / sizeof (sysent[0]),
- sysent,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
-};
diff --git a/sys/kern/init_sysvec.c b/sys/kern/init_sysvec.c
new file mode 100644
index 000000000000..4ef3b16d79c0
--- /dev/null
+++ b/sys/kern/init_sysvec.c
@@ -0,0 +1,29 @@
+/*
+ * sysentvec for native FreeBSD a.out executable format.
+ *
+ * $Id$
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <sys/sysent.h>
+#include <sys/sysproto.h>
+#include <sys/syscall.h>
+#include <sys/signalvar.h>
+#include <machine/md_var.h>
+
+struct sysentvec aout_sysvec = {
+ SYS_MAXSYSCALL,
+ sysent,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ sendsig,
+ sigcode,
+ &szsigcode,
+ 0,
+};
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 9933183aff40..65fdaff03ad1 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: kern_exec.c,v 1.34 1996/01/20 21:36:30 bde Exp $
+ * $Id: kern_exec.c,v 1.35 1996/02/24 14:32:52 peter Exp $
*/
#include <sys/param.h>
@@ -456,15 +456,25 @@ exec_copyout_strings(imgp)
char *stringp, *destp;
int *stack_base;
struct ps_strings *arginfo;
+ int szsigcode;
/*
* Calculate string base and vector table pointers.
+ * Also deal with signal trampoline code for this exec type.
*/
arginfo = PS_STRINGS;
- destp = (caddr_t)arginfo - SPARE_USRSPACE -
+ szsigcode = *(imgp->proc->p_sysent->sv_szsigcode);
+ destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE -
roundup((ARG_MAX - imgp->stringspace), sizeof(char *));
/*
+ * install sigcode
+ */
+ if (szsigcode)
+ copyout(imgp->proc->p_sysent->sv_sigcode,
+ ((caddr_t)arginfo - szsigcode), szsigcode);
+
+ /*
* The '+ 2' is for the null pointers at the end of each of the
* arg and env vector sets
*/
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 0ccb77507ea6..fb0484e2b46e 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_sig.c 8.7 (Berkeley) 4/18/94
- * $Id: kern_sig.c,v 1.17 1996/01/03 21:42:09 wollman Exp $
+ * $Id: kern_sig.c,v 1.18 1996/01/31 12:44:13 davidg Exp $
*/
#include "opt_ktrace.h"
@@ -60,6 +60,8 @@
#include <sys/ktrace.h>
#include <sys/syslog.h>
#include <sys/stat.h>
+#include <sys/imgact.h>
+#include <sys/sysent.h>
#include <machine/cpu.h>
@@ -244,7 +246,7 @@ execsigs(p)
* Reset stack state to the user stack.
* Clear set of signals caught on the signal stack.
*/
- ps->ps_sigstk.ss_flags = SA_DISABLE;
+ ps->ps_sigstk.ss_flags = SS_DISABLE;
ps->ps_sigstk.ss_size = 0;
ps->ps_sigstk.ss_sp = 0;
ps->ps_flags = 0;
@@ -362,13 +364,6 @@ osigvec(p, uap, retval)
sizeof (vec))))
return (error);
#ifdef COMPAT_SUNOS
- /*
- * SunOS uses this bit (4, aka SA_DISABLE) as SV_RESETHAND,
- * `reset to SIG_DFL on delivery'. We have no such option
- * now or ever!
- */
- if (sv->sv_flags & SA_DISABLE)
- return (EINVAL);
sv->sv_flags |= SA_USERTRAMP;
#endif
sv->sv_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */
@@ -471,7 +466,7 @@ osigstack(p, uap, retval)
psp = p->p_sigacts;
ss.ss_sp = psp->ps_sigstk.ss_sp;
- ss.ss_onstack = psp->ps_sigstk.ss_flags & SA_ONSTACK;
+ ss.ss_onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;
if (uap->oss && (error = copyout((caddr_t)&ss, (caddr_t)uap->oss,
sizeof (struct sigstack))))
return (error);
@@ -479,7 +474,7 @@ osigstack(p, uap, retval)
sizeof (ss))) == 0) {
psp->ps_sigstk.ss_sp = ss.ss_sp;
psp->ps_sigstk.ss_size = 0;
- psp->ps_sigstk.ss_flags |= ss.ss_onstack & SA_ONSTACK;
+ psp->ps_sigstk.ss_flags |= ss.ss_onstack & SS_ONSTACK;
psp->ps_flags |= SAS_ALTSTACK;
}
return (error);
@@ -505,7 +500,7 @@ sigaltstack(p, uap, retval)
psp = p->p_sigacts;
if ((psp->ps_flags & SAS_ALTSTACK) == 0)
- psp->ps_sigstk.ss_flags |= SA_DISABLE;
+ psp->ps_sigstk.ss_flags |= SS_DISABLE;
if (uap->oss && (error = copyout((caddr_t)&psp->ps_sigstk,
(caddr_t)uap->oss, sizeof (struct sigaltstack))))
return (error);
@@ -513,8 +508,8 @@ sigaltstack(p, uap, retval)
return (0);
if ((error = copyin((caddr_t)uap->nss, (caddr_t)&ss, sizeof (ss))))
return (error);
- if (ss.ss_flags & SA_DISABLE) {
- if (psp->ps_sigstk.ss_flags & SA_ONSTACK)
+ if (ss.ss_flags & SS_DISABLE) {
+ if (psp->ps_sigstk.ss_flags & SS_ONSTACK)
return (EINVAL);
psp->ps_flags &= ~SAS_ALTSTACK;
psp->ps_sigstk.ss_flags = ss.ss_flags;
@@ -690,7 +685,8 @@ trapsignal(p, signum, code)
ktrpsig(p->p_tracep, signum, ps->ps_sigact[signum],
p->p_sigmask, code);
#endif
- sendsig(ps->ps_sigact[signum], signum, p->p_sigmask, code);
+ (*p->p_sysent->sv_sendsig)(ps->ps_sigact[signum], signum,
+ p->p_sigmask, code);
p->p_sigmask |= ps->ps_catchmask[signum] |
(mask & ~ps->ps_nodefer);
} else {
@@ -1136,7 +1132,7 @@ postsig(signum)
code = ps->ps_code;
ps->ps_code = 0;
}
- sendsig(action, signum, returnmask, code);
+ (*p->p_sysent->sv_sendsig)(action, signum, returnmask, code);
}
}
@@ -1204,8 +1200,14 @@ coredump(p)
int error, error1;
char name[MAXCOMLEN+6]; /* progname.core */
+ /*
+ * If we are setuid/setgid, or if we've changed uid's in the past,
+ * we may be holding privileged information. We must not core!
+ */
if (pcred->p_svuid != pcred->p_ruid || pcred->p_svgid != pcred->p_rgid)
return (EFAULT);
+ if (p->p_flag & P_SUGID)
+ return (EFAULT);
if (ctob(UPAGES + vm->vm_dsize + vm->vm_ssize) >=
p->p_rlimit[RLIMIT_CORE].rlim_cur)
return (EFAULT);
diff --git a/sys/kern/makesyscalls.sh b/sys/kern/makesyscalls.sh
index 976f04234aac..d871d3583a28 100644
--- a/sys/kern/makesyscalls.sh
+++ b/sys/kern/makesyscalls.sh
@@ -1,6 +1,6 @@
#! /bin/sh -
# @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93
-# $Id: makesyscalls.sh,v 1.15 1995/10/07 06:24:07 swallace Exp $
+# $Id: makesyscalls.sh,v 1.16 1995/10/07 23:56:18 swallace Exp $
set -e
@@ -17,7 +17,6 @@ syshide="../sys/syscall-hide.h"
syscallprefix="SYS_"
switchname="sysent"
namesname="syscallnames"
-sysvec=""
# tmp files:
sysdcl="sysent.dcl"
@@ -68,7 +67,6 @@ s/\$//g
syscallprefix = \"$syscallprefix\"
switchname = \"$switchname\"
namesname = \"$namesname\"
- sysvec = \"$sysvec\"
infile = \"$1\"
"'
@@ -353,17 +351,7 @@ s/\$//g
printf("\n#endif /* %s */\n", compat) > syscompatdcl
printf("\n#endif /* !%s */\n", sysproto_h) > syscompatdcl
- printf("};\n\n") > sysent
- if(sysvec != "")
- printf(sysvec) > sysent;
- else {
- printf ("struct sysentvec aout_sysvec = {\n") > sysent
- printf ("\tsizeof (%s) / sizeof (%s[0]),\n", \
- switchname, switchname) > sysent
- printf ("\t%s,\n", switchname) > sysent
- printf ("\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0\n};\n") \
- > sysent
- }
+ printf("};\n") > sysent
printf("};\n") > sysnames
printf("#define\t%sMAXSYSCALL\t%d\n", syscallprefix, syscall) \
> syshdr
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index e270a58dbf16..8ecc51166c61 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
- * $Id: trap.c,v 1.71 1996/01/19 03:57:42 dyson Exp $
+ * $Id: trap.c,v 1.72 1996/02/25 03:02:46 dyson Exp $
*/
/*
@@ -90,7 +90,6 @@ int (*pmath_emulate) __P((struct trapframe *));
extern void trap __P((struct trapframe frame));
extern int trapwrite __P((unsigned addr));
extern void syscall __P((struct trapframe frame));
-extern void linux_syscall __P((struct trapframe frame));
static int trap_pfault __P((struct trapframe *, int));
static void trap_fatal __P((struct trapframe *));
@@ -875,22 +874,26 @@ syscall(frame)
p->p_md.md_regs = (int *)&frame;
params = (caddr_t)frame.tf_esp + sizeof(int);
code = frame.tf_eax;
- /*
- * Need to check if this is a 32 bit or 64 bit syscall.
- */
- if (code == SYS_syscall) {
- /*
- * Code is first argument, followed by actual args.
- */
- code = fuword(params);
- params += sizeof(int);
- } else if (code == SYS___syscall) {
+ if (p->p_sysent->sv_prepsyscall) {
+ (*p->p_sysent->sv_prepsyscall)(&frame, args, &code, &params);
+ } else {
/*
- * Like syscall, but code is a quad, so as to maintain
- * quad alignment for the rest of the arguments.
+ * Need to check if this is a 32 bit or 64 bit syscall.
*/
- code = fuword(params);
- params += sizeof(quad_t);
+ if (code == SYS_syscall) {
+ /*
+ * Code is first argument, followed by actual args.
+ */
+ code = fuword(params);
+ params += sizeof(int);
+ } else if (code == SYS___syscall) {
+ /*
+ * Like syscall, but code is a quad, so as to maintain
+ * quad alignment for the rest of the arguments.
+ */
+ code = fuword(params);
+ params += sizeof(quad_t);
+ }
}
if (p->p_sysent->sv_mask)
@@ -901,7 +904,7 @@ syscall(frame)
else
callp = &p->p_sysent->sv_table[code];
- if ((i = callp->sy_narg * sizeof(int)) &&
+ if (params && (i = callp->sy_narg * sizeof(int)) &&
(error = copyin(params, (caddr_t)args, (u_int)i))) {
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
@@ -933,9 +936,10 @@ syscall(frame)
case ERESTART:
/*
- * Reconstruct pc, assuming lcall $X,y is 7 bytes.
+ * Reconstruct pc, assuming lcall $X,y is 7 bytes,
+ * int 0x80 is 2 bytes. We saved this in tf_err.
*/
- frame.tf_eip -= 7;
+ frame.tf_eip -= frame.tf_err;
break;
case EJUSTRETURN:
@@ -966,98 +970,3 @@ bad:
ktrsysret(p->p_tracep, code, error, rval[0]);
#endif
}
-
-#if defined(COMPAT_LINUX) || defined(LINUX)
-void
-linux_syscall(frame)
- struct trapframe frame;
-{
- struct proc *p = curproc;
- struct sysent *callp;
- u_quad_t sticks;
- int error;
- int rval[2];
- u_int code;
- struct linux_syscall_args {
- int arg1;
- int arg2;
- int arg3;
- int arg4;
- int arg5;
- } args;
-
- args.arg1 = frame.tf_ebx;
- args.arg2 = frame.tf_ecx;
- args.arg3 = frame.tf_edx;
- args.arg4 = frame.tf_esi;
- args.arg5 = frame.tf_edi;
-
- sticks = p->p_sticks;
- if (ISPL(frame.tf_cs) != SEL_UPL)
- panic("linux syscall");
-
- p->p_md.md_regs = (int *)&frame;
- code = frame.tf_eax;
-
- if (p->p_sysent->sv_mask)
- code &= p->p_sysent->sv_mask;
-
- if (code >= p->p_sysent->sv_size)
- callp = &p->p_sysent->sv_table[0];
- else
- callp = &p->p_sysent->sv_table[code];
-
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p->p_tracep, code, callp->sy_narg, (int *)&args);
-#endif
-
- rval[0] = 0;
-
- error = (*callp->sy_call)(p, &args, rval);
-
- switch (error) {
-
- case 0:
- /*
- * Reinitialize proc pointer `p' as it may be different
- * if this is a child returning from fork syscall.
- */
- p = curproc;
- frame.tf_eax = rval[0];
- frame.tf_eflags &= ~PSL_C;
- break;
-
- case ERESTART:
- /* Reconstruct pc, subtract size of int 0x80 */
- frame.tf_eip -= 2;
- break;
-
- case EJUSTRETURN:
- break;
-
- default:
- if (p->p_sysent->sv_errsize)
- if (error >= p->p_sysent->sv_errsize)
- error = -1; /* XXX */
- else
- error = p->p_sysent->sv_errtbl[error];
- frame.tf_eax = -error;
- frame.tf_eflags |= PSL_C;
- break;
- }
-
- if (frame.tf_eflags & PSL_T) {
- /* Traced syscall. */
- frame.tf_eflags &= ~PSL_T;
- trapsignal(p, SIGTRAP, 0);
- }
-
- userret(p, &frame, sticks);
-
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p->p_tracep, code, error, rval[0]);
-#endif
-}
-#endif /* COMPAT_LINUX || LINUX */