summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2016-05-21 00:56:45 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2016-05-21 00:56:45 +0000
commit1fbc8c228fe0fb56e2182ad5a2e0de8e8680741d (patch)
treeffe3fd23c29744463f434d9eed1b663384113fb9
parent4450afa6a6d9aec03fedaef2f2e2e5e73e9f2531 (diff)
hand-massage sendsig() and sys_sigreturn() to be much more similar.
ok guenther kettenis
-rw-r--r--sys/arch/alpha/alpha/machdep.c69
-rw-r--r--sys/arch/amd64/amd64/machdep.c24
-rw-r--r--sys/arch/arm/arm/sig_machdep.c62
-rw-r--r--sys/arch/hppa/hppa/machdep.c45
-rw-r--r--sys/arch/m88k/m88k/sig_machdep.c32
-rw-r--r--sys/arch/macppc/macppc/machdep.c30
-rw-r--r--sys/arch/mips64/mips64/sendsig.c66
-rw-r--r--sys/arch/sh/sh/sh_machdep.c28
-rw-r--r--sys/arch/socppc/socppc/machdep.c26
-rw-r--r--sys/arch/sparc/sparc/machdep.c56
10 files changed, 110 insertions, 328 deletions
diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c
index 97c12d9ba81..84b92688741 100644
--- a/sys/arch/alpha/alpha/machdep.c
+++ b/sys/arch/alpha/alpha/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.173 2016/05/11 17:59:58 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.174 2016/05/21 00:56:41 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.210 2000/06/01 17:12:38 thorpej Exp $ */
/*-
@@ -1401,15 +1401,11 @@ pid_t sigpid = 0;
* Send an interrupt to process.
*/
void
-sendsig(catcher, sig, mask, code, type, val)
- sig_t catcher;
- int sig, mask;
- u_long code;
- int type;
- union sigval val;
+sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
+ union sigval val)
{
struct proc *p = curproc;
- struct sigcontext *scp, ksc;
+ struct sigcontext ksc, *scp;
struct fpreg *fpregs = (struct fpreg *)&ksc.sc_fpregs;
struct trapframe *frame;
struct sigacts *psp = p->p_p->ps_sigacts;
@@ -1436,11 +1432,6 @@ sendsig(catcher, sig, mask, code, type, val)
p->p_sigstk.ss_size - rndfsize);
else
scp = (struct sigcontext *)(oldsp - rndfsize);
-#ifdef DEBUG
- if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
- printf("sendsig(%d): sig %d ssp %p usp %p\n", p->p_pid,
- sig, &ksc, scp);
-#endif
/*
* Build the signal context to be used by sigreturn.
@@ -1452,7 +1443,6 @@ sendsig(catcher, sig, mask, code, type, val)
/* copy the registers. */
frametoreg(frame, (struct reg *)ksc.sc_regs);
- ksc.sc_regs[R_ZERO] = 0xACEDBADE; /* magic number */
ksc.sc_regs[R_SP] = oldsp;
/* save the floating-point state, if necessary, then copy it. */
@@ -1480,11 +1470,6 @@ sendsig(catcher, sig, mask, code, type, val)
ksc.sc_cookie = (long)scp ^ p->p_p->ps_sigcookie;
if (copyout((caddr_t)&ksc, (caddr_t)scp, kscsize) != 0) {
trash:
-#ifdef DEBUG
- if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
- printf("sendsig(%d): copyout failed on sig %d\n",
- p->p_pid, sig);
-#endif
/*
* Process has trashed its stack; give it an illegal
* instruction to halt it in its tracks.
@@ -1492,11 +1477,6 @@ trash:
sigexit(p, SIGILL);
/* NOTREACHED */
}
-#ifdef DEBUG
- if (sigdebug & SDB_FOLLOW)
- printf("sendsig(%d): sig %d scp %p code %lx\n", p->p_pid, sig,
- scp, code);
-#endif
/*
* Set up the registers to return to sigcode.
@@ -1507,15 +1487,6 @@ trash:
frame->tf_regs[FRAME_A2] = (u_int64_t)scp;
frame->tf_regs[FRAME_T12] = (u_int64_t)catcher; /* t12 is pv */
alpha_pal_wrusp((unsigned long)scp);
-
-#ifdef DEBUG
- if (sigdebug & SDB_FOLLOW)
- printf("sendsig(%d): pc %lx, catcher %lx\n", p->p_pid,
- frame->tf_regs[FRAME_PC], frame->tf_regs[FRAME_A3]);
- if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
- printf("sendsig(%d): sig %d returns\n",
- p->p_pid, sig);
-#endif
}
/*
@@ -1530,42 +1501,24 @@ trash:
*/
/* ARGSUSED */
int
-sys_sigreturn(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
+sys_sigreturn(struct proc *p, void *v, register_t *retval)
{
struct sys_sigreturn_args /* {
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
- struct sigcontext ksc;
+ struct sigcontext ksc, *scp = SCARG(uap, sigcntxp);
struct fpreg *fpregs = (struct fpreg *)&ksc.sc_fpregs;
- struct sigcontext *scp = SCARG(uap, sigcntxp);
int error;
-#ifdef DEBUG
- if (sigdebug & SDB_FOLLOW)
- printf("sigreturn: pid %d, scp %p\n", p->p_pid, scp);
-#endif
-
if (PROC_PC(p) != p->p_p->ps_sigcoderet) {
- printf("%s(%d): sigreturn not from tramp [pc 0x%lx 0x%lx]\n",
- p->p_comm, p->p_pid, PROC_PC(p), p->p_p->ps_sigcoderet);
sigexit(p, SIGILL);
return (EPERM);
}
- /*
- * Test and fetch the context structure.
- * We grab it all at once for speed.
- */
if ((error = copyin(scp, &ksc, sizeof(ksc))) != 0)
return (error);
if (ksc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
- printf("%s(%d): cookie %lx should have been %lx\n",
- p->p_comm, p->p_pid, ksc.sc_cookie,
- (long)scp ^ p->p_p->ps_sigcookie);
sigexit(p, SIGILL);
return (EFAULT);
}
@@ -1573,11 +1526,8 @@ sys_sigreturn(p, v, retval)
/* Prevent reuse of the sigcontext cookie */
ksc.sc_cookie = 0;
(void)copyout(&ksc.sc_cookie, (caddr_t)scp +
- offsetof(struct sigcontext, sc_cookie),
- sizeof (ksc.sc_cookie));
+ offsetof(struct sigcontext, sc_cookie), sizeof (ksc.sc_cookie));
- if (ksc.sc_regs[R_ZERO] != 0xACEDBADE) /* magic number */
- return (EINVAL);
/*
* Restore the user-supplied information
*/
@@ -1599,11 +1549,6 @@ sys_sigreturn(p, v, retval)
p->p_addr->u_pcb.pcb_fp.fpr_cr = ksc.sc_fpcr;
p->p_md.md_flags = ksc.sc_fp_control & MDP_FP_C;
#endif
-
-#ifdef DEBUG
- if (sigdebug & SDB_FOLLOW)
- printf("sigreturn(%d): returns\n", p->p_pid);
-#endif
return (EJUSTRETURN);
}
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index 71f626252b4..de9f481a2d4 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.220 2016/05/16 01:48:28 mlarkin Exp $ */
+/* $OpenBSD: machdep.c,v 1.221 2016/05/21 00:56:43 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -528,12 +528,6 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
register_t sp, scp, sip;
u_long sss;
-#ifdef DEBUG
- if ((sigdebug & SDB_FOLLOW) && (!sigpid || p->p_pid == sigpid))
- printf("sendsig: %s[%d] sig %d catcher %p\n",
- p->p_comm, p->p_pid, sig, catcher);
-#endif
-
memcpy(&ksc, tf, sizeof(*tf));
bzero((char *)&ksc + sizeof(*tf), sizeof(ksc) - sizeof(*tf));
ksc.sc_mask = mask;
@@ -588,12 +582,6 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
tf->tf_rflags &= ~(PSL_T|PSL_D|PSL_VM|PSL_AC);
tf->tf_rsp = scp;
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
-
-#ifdef DEBUG
- if ((sigdebug & SDB_FOLLOW) && (!sigpid || p->p_pid == sigpid))
- printf("sendsig(%d): pc 0x%llx, catcher 0x%llx\n", p->p_pid,
- tf->tf_rip, tf->tf_rax);
-#endif
}
/*
@@ -612,13 +600,11 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
struct sys_sigreturn_args /* {
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
- struct sigcontext *scp = SCARG(uap, sigcntxp), ksc;
+ struct sigcontext ksc, *scp = SCARG(uap, sigcntxp);
struct trapframe *tf = p->p_md.md_regs;
int error;
if (PROC_PC(p) != p->p_p->ps_sigcoderet) {
- printf("%s(%d): sigreturn not from tramp [pc 0x%llx %lx]\n",
- p->p_comm, p->p_pid, PROC_PC(p), p->p_p->ps_sigcoderet);
sigexit(p, SIGILL);
return (EPERM);
}
@@ -627,9 +613,6 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
return (error);
if (ksc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
- printf("%s(%d): cookie %lx should have been %lx\n",
- p->p_comm, p->p_pid, ksc.sc_cookie,
- (long)scp ^ p->p_p->ps_sigcookie);
sigexit(p, SIGILL);
return (EFAULT);
}
@@ -637,8 +620,7 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
/* Prevent reuse of the sigcontext cookie */
ksc.sc_cookie = 0;
(void)copyout(&ksc.sc_cookie, (caddr_t)scp +
- offsetof(struct sigcontext, sc_cookie),
- sizeof (ksc.sc_cookie));
+ offsetof(struct sigcontext, sc_cookie), sizeof (ksc.sc_cookie));
if (((ksc.sc_rflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 ||
!USERMODE(ksc.sc_cs, ksc.sc_eflags))
diff --git a/sys/arch/arm/arm/sig_machdep.c b/sys/arch/arm/arm/sig_machdep.c
index 6f308d4cab7..43744c3c1ce 100644
--- a/sys/arch/arm/arm/sig_machdep.c
+++ b/sys/arch/arm/arm/sig_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sig_machdep.c,v 1.13 2016/05/10 18:39:43 deraadt Exp $ */
+/* $OpenBSD: sig_machdep.c,v 1.14 2016/05/21 00:56:43 deraadt Exp $ */
/* $NetBSD: sig_machdep.c,v 1.22 2003/10/08 00:28:41 thorpej Exp $ */
/*
@@ -183,64 +183,58 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
struct sys_sigreturn_args /* {
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
- struct sigcontext *scp = SCARG(uap, sigcntxp), context;
+ struct sigcontext ksc, *scp = SCARG(uap, sigcntxp);
struct trapframe *tf;
if (PROC_PC(p) != p->p_p->ps_sigcoderet) {
- printf("%s(%d): sigreturn not from tramp [pc 0x%lx %lx]\n",
- p->p_comm, p->p_pid, PROC_PC(p), p->p_p->ps_sigcoderet);
sigexit(p, SIGILL);
return (EPERM);
}
- if (copyin(scp, &context, sizeof(*scp)) != 0)
+ if (copyin(scp, &ksc, sizeof(*scp)) != 0)
return (EFAULT);
- if (context.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
- printf("%s(%d): cookie %lx should have been %lx\n",
- p->p_comm, p->p_pid, context.sc_cookie,
- (long)scp ^ p->p_p->ps_sigcookie);
+ if (ksc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
sigexit(p, SIGILL);
return (EFAULT);
}
/* Prevent reuse of the sigcontext cookie */
- context.sc_cookie = 0;
- (void)copyout(&context.sc_cookie, (caddr_t)scp +
- offsetof(struct sigcontext, sc_cookie),
- sizeof (context.sc_cookie));
+ ksc.sc_cookie = 0;
+ (void)copyout(&ksc.sc_cookie, (caddr_t)scp +
+ offsetof(struct sigcontext, sc_cookie), sizeof (ksc.sc_cookie));
/*
* Make sure the processor mode has not been tampered with and
* interrupts have not been disabled.
*/
- if ((context.sc_spsr & PSR_MODE) != PSR_USR32_MODE ||
- (context.sc_spsr & (PSR_I | PSR_F)) != 0)
+ if ((ksc.sc_spsr & PSR_MODE) != PSR_USR32_MODE ||
+ (ksc.sc_spsr & (PSR_I | PSR_F)) != 0)
return (EINVAL);
/* Restore register context. */
tf = process_frame(p);
- tf->tf_r0 = context.sc_r0;
- tf->tf_r1 = context.sc_r1;
- tf->tf_r2 = context.sc_r2;
- tf->tf_r3 = context.sc_r3;
- tf->tf_r4 = context.sc_r4;
- tf->tf_r5 = context.sc_r5;
- tf->tf_r6 = context.sc_r6;
- tf->tf_r7 = context.sc_r7;
- tf->tf_r8 = context.sc_r8;
- tf->tf_r9 = context.sc_r9;
- tf->tf_r10 = context.sc_r10;
- tf->tf_r11 = context.sc_r11;
- tf->tf_r12 = context.sc_r12;
- tf->tf_usr_sp = context.sc_usr_sp;
- tf->tf_usr_lr = context.sc_usr_lr;
- tf->tf_svc_lr = context.sc_svc_lr;
- tf->tf_pc = context.sc_pc;
- tf->tf_spsr = context.sc_spsr;
+ tf->tf_r0 = ksc.sc_r0;
+ tf->tf_r1 = ksc.sc_r1;
+ tf->tf_r2 = ksc.sc_r2;
+ tf->tf_r3 = ksc.sc_r3;
+ tf->tf_r4 = ksc.sc_r4;
+ tf->tf_r5 = ksc.sc_r5;
+ tf->tf_r6 = ksc.sc_r6;
+ tf->tf_r7 = ksc.sc_r7;
+ tf->tf_r8 = ksc.sc_r8;
+ tf->tf_r9 = ksc.sc_r9;
+ tf->tf_r10 = ksc.sc_r10;
+ tf->tf_r11 = ksc.sc_r11;
+ tf->tf_r12 = ksc.sc_r12;
+ tf->tf_usr_sp = ksc.sc_usr_sp;
+ tf->tf_usr_lr = ksc.sc_usr_lr;
+ tf->tf_svc_lr = ksc.sc_svc_lr;
+ tf->tf_pc = ksc.sc_pc;
+ tf->tf_spsr = ksc.sc_spsr;
/* Restore signal mask. */
- p->p_sigmask = context.sc_mask & ~sigcantmask;
+ p->p_sigmask = ksc.sc_mask & ~sigcantmask;
return (EJUSTRETURN);
}
diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c
index 98578044850..75105b912a3 100644
--- a/sys/arch/hppa/hppa/machdep.c
+++ b/sys/arch/hppa/hppa/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.244 2016/05/10 18:39:44 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.245 2016/05/21 00:56:43 deraadt Exp $ */
/*
* Copyright (c) 1999-2003 Michael Shalayeff
@@ -1212,12 +1212,6 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
register_t scp, sip;
int sss;
-#ifdef DEBUG
- if ((sigdebug & SDB_FOLLOW) && (!sigpid || p->p_pid == sigpid))
- printf("sendsig: %s[%d] sig %d catcher %p\n",
- p->p_comm, p->p_pid, sig, catcher);
-#endif
-
/* Save the FPU context first. */
fpu_proc_save(p);
@@ -1237,12 +1231,6 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
sss += (sizeof(ksi) + 63) & ~63;
}
-#ifdef DEBUG
- if ((tf->tf_iioq_head & ~PAGE_MASK) == SYSCALLGATE)
- printf("sendsig: interrupted syscall at 0x%x:0x%x flags %b\n",
- tf->tf_iioq_head, tf->tf_iioq_tail, tf->tf_ipsw, PSL_BITS);
-#endif
-
bzero(&ksc, sizeof(ksc));
ksc.sc_mask = mask;
ksc.sc_fp = scp + sss;
@@ -1297,12 +1285,6 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
tf->tf_iisq_tail = tf->tf_iisq_head = pcb->pcb_space;
/* disable tracing in the trapframe */
-#ifdef DEBUG
- if ((sigdebug & SDB_FOLLOW) && (!sigpid || p->p_pid == sigpid))
- printf("sendsig(%d): sig %d scp %p fp %p sp 0x%x\n",
- p->p_pid, sig, scp, ksc.sc_fp, tf->tf_sp);
-#endif
-
ksc.sc_cookie = (long)scp ^ p->p_p->ps_sigcookie;
if (copyout(&ksc, (void *)scp, sizeof(ksc)))
sigexit(p, SIGILL);
@@ -1312,12 +1294,6 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
if (copyout(&ksi, (void *)sip, sizeof(ksi)))
sigexit(p, SIGILL);
}
-
-#ifdef DEBUG
- if ((sigdebug & SDB_FOLLOW) && (!sigpid || p->p_pid == sigpid))
- printf("sendsig(%d): pc 0x%x catcher 0x%x\n", p->p_pid,
- tf->tf_iioq_head, tf->tf_arg3);
-#endif
}
int
@@ -1326,22 +1302,15 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
struct sys_sigreturn_args /* {
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
- struct sigcontext *scp = SCARG(uap, sigcntxp), ksc;
+ struct sigcontext ksc, *scp = SCARG(uap, sigcntxp);
struct trapframe *tf = p->p_md.md_regs;
int error;
if (PROC_PC(p) != p->p_p->ps_sigcoderet) {
- printf("%s(%d): sigreturn not from tramp [pc 0x%lx 0x%lx]\n",
- p->p_comm, p->p_pid, PROC_PC(p), p->p_p->ps_sigcoderet);
sigexit(p, SIGILL);
return (EPERM);
}
-#ifdef DEBUG
- if ((sigdebug & SDB_FOLLOW) && (!sigpid || p->p_pid == sigpid))
- printf("sigreturn: pid %d, scp %p\n", p->p_pid, scp);
-#endif
-
/* Flush the FPU context first. */
fpu_proc_flush(p);
@@ -1349,9 +1318,6 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
return (error);
if (ksc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
- printf("%s(%d): cookie %lx should have been %lx\n",
- p->p_comm, p->p_pid, ksc.sc_cookie,
- (long)scp ^ p->p_p->ps_sigcookie);
sigexit(p, SIGILL);
return (EFAULT);
}
@@ -1359,8 +1325,7 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
/* Prevent reuse of the sigcontext cookie */
ksc.sc_cookie = 0;
(void)copyout(&ksc.sc_cookie, (caddr_t)scp +
- offsetof(struct sigcontext, sc_cookie),
- sizeof (ksc.sc_cookie));
+ offsetof(struct sigcontext, sc_cookie), sizeof (ksc.sc_cookie));
#define PSL_MBS (PSL_C|PSL_Q|PSL_P|PSL_D|PSL_I)
#define PSL_MBZ (PSL_Y|PSL_Z|PSL_S|PSL_X|PSL_M|PSL_R)
@@ -1416,10 +1381,6 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
tf->tf_iisq_tail = p->p_addr->u_pcb.pcb_space;
tf->tf_ipsw = ksc.sc_ps | (curcpu()->ci_psw & PSL_O);
-#ifdef DEBUG
- if ((sigdebug & SDB_FOLLOW) && (!sigpid || p->p_pid == sigpid))
- printf("sigreturn(%d): returns\n", p->p_pid);
-#endif
return (EJUSTRETURN);
}
diff --git a/sys/arch/m88k/m88k/sig_machdep.c b/sys/arch/m88k/m88k/sig_machdep.c
index b1fef7fc38f..cd282df35f5 100644
--- a/sys/arch/m88k/m88k/sig_machdep.c
+++ b/sys/arch/m88k/m88k/sig_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sig_machdep.c,v 1.24 2016/05/10 18:39:46 deraadt Exp $ */
+/* $OpenBSD: sig_machdep.c,v 1.25 2016/05/21 00:56:43 deraadt Exp $ */
/*
* Copyright (c) 2014 Miodrag Vallat.
*
@@ -134,13 +134,6 @@ sendsig(sig_t catcher, int sig, int mask, unsigned long code, int type,
fp = (struct sigframe *)addr;
-#ifdef DEBUG
- if ((sigdebug & SDB_FOLLOW) ||
- ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid))
- printf("sendsig(%d): sig %d ssp %p usp %p scp %p\n",
- p->p_pid, sig, &sf, fp, &fp->sf_sc);
-#endif
-
/*
* Build the signal context to be used by sigreturn.
*/
@@ -207,26 +200,21 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
struct sys_sigreturn_args /* {
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
- struct sigcontext *scp = SCARG(uap, sigcntxp);
+ struct sigcontext ksc, *scp = SCARG(uap, sigcntxp);
struct trapframe *tf;
- struct sigcontext ksc;
if (PROC_PC(p) != p->p_p->ps_sigcoderet) {
- printf("%s(%d): sigreturn not from tramp [pc 0x%llx %llx]\n",
- p->p_comm, p->p_pid, PROC_PC(p), p->p_p->ps_sigcoderet);
sigexit(p, SIGILL);
return (EPERM);
}
if (((vaddr_t)scp & 3) != 0)
- return (EINVAL);
+ return (EFAULT);
+
if ((error = copyin((caddr_t)scp, (caddr_t)&ksc, sizeof(*scp))))
return (error);
if (ksc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
- printf("%s(%d): cookie %lx should have been %lx\n",
- p->p_comm, p->p_pid, ksc.sc_cookie,
- (long)scp ^ p->p_p->ps_sigcookie);
sigexit(p, SIGILL);
return (EFAULT);
}
@@ -234,23 +222,21 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
/* Prevent reuse of the sigcontext cookie */
ksc.sc_cookie = 0;
(void)copyout(&ksc.sc_cookie, (caddr_t)scp +
- offsetof(struct sigcontext, sc_cookie),
- sizeof (ksc.sc_cookie));
+ offsetof(struct sigcontext, sc_cookie), sizeof (ksc.sc_cookie));
tf = p->p_md.md_tf;
- scp = &ksc;
- if ((((struct reg *)&scp->sc_regs)->epsr ^ tf->tf_regs.epsr) &
+ if ((((struct reg *)&ksc.sc_regs)->epsr ^ tf->tf_regs.epsr) &
PSR_USERSTATIC)
return (EINVAL);
- bcopy((const void *)&scp->sc_regs, (caddr_t)&tf->tf_regs,
- sizeof(scp->sc_regs));
+ bcopy((const void *)&ksc.sc_regs, (caddr_t)&tf->tf_regs,
+ sizeof(ksc.sc_regs));
/*
* Restore the user supplied information
*/
- p->p_sigmask = scp->sc_mask & ~sigcantmask;
+ p->p_sigmask = ksc.sc_mask & ~sigcantmask;
#ifdef M88100
if (CPU_IS88100) {
diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c
index 94f74873124..b296e3d9f9e 100644
--- a/sys/arch/macppc/macppc/machdep.c
+++ b/sys/arch/macppc/macppc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.175 2016/05/11 20:19:00 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.176 2016/05/21 00:56:43 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -508,41 +508,35 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
struct sys_sigreturn_args /* {
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
- struct sigcontext sc, *scp = SCARG(uap, sigcntxp);
+ struct sigcontext ksc, *scp = SCARG(uap, sigcntxp);
struct trapframe *tf;
int error;
if (PROC_PC(p) != p->p_p->ps_sigcoderet) {
- printf("%s(%d): sigreturn not from tramp [pc 0x%x 0x%lx]\n",
- p->p_comm, p->p_pid, PROC_PC(p), p->p_p->ps_sigcoderet);
sigexit(p, SIGILL);
return (EPERM);
}
- if ((error = copyin(scp, &sc, sizeof sc)))
+ if ((error = copyin(scp, &ksc, sizeof ksc)))
return error;
- if (sc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
- printf("%s(%d): cookie %lx should have been %lx\n",
- p->p_comm, p->p_pid, sc.sc_cookie,
- (long)scp ^ p->p_p->ps_sigcookie);
+ if (ksc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
sigexit(p, SIGILL);
return (EFAULT);
}
/* Prevent reuse of the sigcontext cookie */
- sc.sc_cookie = 0;
- (void)copyout(&sc.sc_cookie, (caddr_t)scp +
- offsetof(struct sigcontext, sc_cookie),
- sizeof (sc.sc_cookie));
+ ksc.sc_cookie = 0;
+ (void)copyout(&ksc.sc_cookie, (caddr_t)scp +
+ offsetof(struct sigcontext, sc_cookie), sizeof (ksc.sc_cookie));
tf = trapframe(p);
- sc.sc_frame.srr1 &= ~PSL_VEC;
- sc.sc_frame.srr1 |= (tf->srr1 & PSL_VEC);
- if ((sc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
+ ksc.sc_frame.srr1 &= ~PSL_VEC;
+ ksc.sc_frame.srr1 |= (tf->srr1 & PSL_VEC);
+ if ((ksc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
return EINVAL;
- bcopy(&sc.sc_frame, tf, sizeof *tf);
- p->p_sigmask = sc.sc_mask & ~sigcantmask;
+ bcopy(&ksc.sc_frame, tf, sizeof *tf);
+ p->p_sigmask = ksc.sc_mask & ~sigcantmask;
return EJUSTRETURN;
}
diff --git a/sys/arch/mips64/mips64/sendsig.c b/sys/arch/mips64/mips64/sendsig.c
index 45f0ee16996..3e6ebfd02e8 100644
--- a/sys/arch/mips64/mips64/sendsig.c
+++ b/sys/arch/mips64/mips64/sendsig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sendsig.c,v 1.26 2016/05/10 18:39:47 deraadt Exp $ */
+/* $OpenBSD: sendsig.c,v 1.27 2016/05/21 00:56:43 deraadt Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
@@ -100,12 +100,8 @@ pid_t sigpid = 0;
* Send an interrupt to process.
*/
void
-sendsig(catcher, sig, mask, code, type, val)
- sig_t catcher;
- int sig, mask;
- u_long code;
- int type;
- union sigval val;
+sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
+ union sigval val)
{
struct cpu_info *ci = curcpu();
struct proc *p = curproc;
@@ -129,12 +125,6 @@ sendsig(catcher, sig, mask, code, type, val)
p->p_sigstk.ss_size - fsize);
else
fp = (struct sigframe *)(regs->sp - fsize);
-#ifdef DEBUG
- if ((sigdebug & SDB_FOLLOW) ||
- ((sigdebug & SDB_KSTACK) && (p->p_pid == sigpid)))
- printf("sendsig(%d): sig %d ssp %p usp %p scp %p\n",
- p->p_pid, sig, &ksc, fp, &fp->sf_sc);
-#endif
/*
* Build the signal context to be used by sigreturn.
*/
@@ -143,7 +133,6 @@ sendsig(catcher, sig, mask, code, type, val)
ksc.sc_pc = regs->pc;
ksc.mullo = regs->mullo;
ksc.mulhi = regs->mulhi;
- ksc.sc_regs[ZERO] = 0xACEDBADE; /* magic number */
bcopy((caddr_t)&regs->ast, (caddr_t)&ksc.sc_regs[1],
sizeof(ksc.sc_regs) - sizeof(register_t));
ksc.sc_fpused = p->p_md.md_flags & MDP_FPUSED;
@@ -187,12 +176,6 @@ bail:
regs->sp = (register_t)fp;
regs->ra = p->p_p->ps_sigcode;
-#ifdef DEBUG
- if ((sigdebug & SDB_FOLLOW) ||
- ((sigdebug & SDB_KSTACK) && (p->p_pid == sigpid)))
- printf("sendsig(%d): sig %d returns\n",
- p->p_pid, sig);
-#endif
}
/*
@@ -207,29 +190,17 @@ bail:
*/
/* ARGSUSED */
int
-sys_sigreturn(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
+sys_sigreturn(struct proc *p, void *v, register_t *retval)
{
struct cpu_info *ci = curcpu();
struct sys_sigreturn_args /* {
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
- struct sigcontext *scp = SCARG(uap, sigcntxp);
- struct trapframe *regs;
- struct sigcontext ksc;
+ struct sigcontext ksc, *scp = SCARG(uap, sigcntxp);
+ struct trapframe *regs = p->p_md.md_regs;
int error;
-#ifdef DEBUG
- if (sigdebug & SDB_FOLLOW)
- printf("sigreturn: pid %d, scp %p\n", p->p_pid, scp);
-#endif
- regs = p->p_md.md_regs;
-
if (PROC_PC(p) != p->p_p->ps_sigcoderet) {
- printf("%s(%d): sigreturn not from tramp [pc 0x%lx 0x%lx]\n",
- p->p_comm, p->p_pid, PROC_PC(p), p->p_p->ps_sigcoderet);
sigexit(p, SIGILL);
return (EPERM);
}
@@ -243,9 +214,6 @@ sys_sigreturn(p, v, retval)
return (error);
if (ksc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
- printf("%s(%d): cookie %lx should have been %lx\n",
- p->p_comm, p->p_pid, ksc.sc_cookie,
- (long)scp ^ p->p_p->ps_sigcookie);
sigexit(p, SIGILL);
return (EFAULT);
}
@@ -253,24 +221,22 @@ sys_sigreturn(p, v, retval)
/* Prevent reuse of the sigcontext cookie */
ksc.sc_cookie = 0;
(void)copyout(&ksc.sc_cookie, (caddr_t)scp +
- offsetof(struct sigcontext, sc_cookie),
- sizeof (ksc.sc_cookie));
+ offsetof(struct sigcontext, sc_cookie), sizeof (ksc.sc_cookie));
- scp = &ksc;
/*
* Restore the user supplied information
*/
- p->p_sigmask = scp->sc_mask &~ sigcantmask;
- regs->pc = scp->sc_pc;
- regs->mullo = scp->mullo;
- regs->mulhi = scp->mulhi;
+ p->p_sigmask = ksc.sc_mask &~ sigcantmask;
+ regs->pc = ksc.sc_pc;
+ regs->mullo = ksc.mullo;
+ regs->mulhi = ksc.mulhi;
regs->sr &= ~SR_COP_1_BIT; /* Zap current FP state */
if (p == ci->ci_fpuproc)
ci->ci_fpuproc = NULL;
- bcopy((caddr_t)&scp->sc_regs[1], (caddr_t)&regs->ast,
- sizeof(scp->sc_regs) - sizeof(register_t));
- if (scp->sc_fpused)
- bcopy((caddr_t)scp->sc_fpregs, (caddr_t)&p->p_md.md_regs->f0,
- sizeof(scp->sc_fpregs));
+ bcopy((caddr_t)&ksc.sc_regs[1], (caddr_t)&regs->ast,
+ sizeof(ksc.sc_regs) - sizeof(register_t));
+ if (ksc.sc_fpused)
+ bcopy((caddr_t)ksc.sc_fpregs, (caddr_t)&p->p_md.md_regs->f0,
+ sizeof(ksc.sc_fpregs));
return (EJUSTRETURN);
}
diff --git a/sys/arch/sh/sh/sh_machdep.c b/sys/arch/sh/sh/sh_machdep.c
index 5510c30f80f..ec1c393a77d 100644
--- a/sys/arch/sh/sh/sh_machdep.c
+++ b/sys/arch/sh/sh/sh_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sh_machdep.c,v 1.45 2016/05/18 20:21:13 guenther Exp $ */
+/* $OpenBSD: sh_machdep.c,v 1.46 2016/05/21 00:56:44 deraadt Exp $ */
/* $NetBSD: sh3_machdep.c,v 1.59 2006/03/04 01:13:36 uwe Exp $ */
/*
@@ -520,50 +520,44 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
struct sys_sigreturn_args /* {
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
- struct sigcontext *scp = SCARG(uap, sigcntxp), context;
+ struct sigcontext ksc, *scp = SCARG(uap, sigcntxp);
struct trapframe *tf;
int error;
if (PROC_PC(p) != p->p_p->ps_sigcoderet) {
- printf("%s(%d): sigreturn not from sigtramp [pc 0x%x 0x%lx]\n",
- p->p_comm, p->p_pid, PROC_PC(p), p->p_p->ps_sigcoderet);
sigexit(p, SIGILL);
return (EPERM);
}
- if ((error = copyin(scp, &context, sizeof(*scp))) != 0)
+ if ((error = copyin(scp, &ksc, sizeof(*scp))) != 0)
return (error);
- if (context.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
- printf("%s(%d): cookie %lx should have been %lx\n",
- p->p_comm, p->p_pid, context.sc_cookie,
- (long)scp ^ p->p_p->ps_sigcookie);
+ if (ksc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
sigexit(p, SIGILL);
return (EFAULT);
}
/* Prevent reuse of the sigcontext cookie */
- context.sc_cookie = 0;
- (void)copyout(&context.sc_cookie, (caddr_t)scp +
- offsetof(struct sigcontext, sc_cookie),
- sizeof (context.sc_cookie));
+ ksc.sc_cookie = 0;
+ (void)copyout(&ksc.sc_cookie, (caddr_t)scp +
+ offsetof(struct sigcontext, sc_cookie), sizeof(ksc.sc_cookie));
/* Restore signal context. */
tf = p->p_md.md_regs;
/* Check for security violations. */
- if (((context.sc_reg[1] /* ssr */ ^ tf->tf_ssr) & PSL_USERSTATIC) != 0)
+ if (((ksc.sc_reg[1] /* ssr */ ^ tf->tf_ssr) & PSL_USERSTATIC) != 0)
return (EINVAL);
- memcpy(&tf->tf_spc, context.sc_reg, sizeof(context.sc_reg));
+ memcpy(&tf->tf_spc, ksc.sc_reg, sizeof(ksc.sc_reg));
#ifdef SH4
if (CPU_IS_SH4)
- fpu_restore((struct fpreg *)&context.sc_fpreg);
+ fpu_restore((struct fpreg *)&ksc.sc_fpreg);
#endif
/* Restore signal mask. */
- p->p_sigmask = context.sc_mask & ~sigcantmask;
+ p->p_sigmask = ksc.sc_mask & ~sigcantmask;
return (EJUSTRETURN);
}
diff --git a/sys/arch/socppc/socppc/machdep.c b/sys/arch/socppc/socppc/machdep.c
index 7e138ae83cb..bfb5509d91a 100644
--- a/sys/arch/socppc/socppc/machdep.c
+++ b/sys/arch/socppc/socppc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.67 2016/05/11 20:19:01 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.68 2016/05/21 00:56:44 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -535,39 +535,33 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
struct sys_sigreturn_args /* {
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
- struct sigcontext sc, *scp = SCARG(uap, sigcntxp);
+ struct sigcontext ksc, *scp = SCARG(uap, sigcntxp);
struct trapframe *tf;
int error;
if (PROC_PC(p) != p->p_p->ps_sigcoderet) {
- printf("%s(%d): sigreturn not from tramp [pc 0x%x 0x%lx]\n",
- p->p_comm, p->p_pid, PROC_PC(p), p->p_p->ps_sigcoderet);
sigexit(p, SIGILL);
return (EPERM);
}
- if ((error = copyin(scp, &sc, sizeof sc)))
+ if ((error = copyin(scp, &ksc, sizeof sc)))
return error;
- if (sc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
- printf("%s(%d): cookie %lx should have been %lx\n",
- p->p_comm, p->p_pid, sc.sc_cookie,
- (long)scp ^ p->p_p->ps_sigcookie);
+ if (ksc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
sigexit(p, SIGILL);
return (EFAULT);
}
/* Prevent reuse of the sigcontext cookie */
- sc.sc_cookie = 0;
- (void)copyout(&sc.sc_cookie, (caddr_t)scp +
- offsetof(struct sigcontext, sc_cookie),
- sizeof (sc.sc_cookie));
+ ksc.sc_cookie = 0;
+ (void)copyout(&ksc.sc_cookie, (caddr_t)scp +
+ offsetof(struct sigcontext, sc_cookie), sizeof (ksc.sc_cookie));
tf = trapframe(p);
- if ((sc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
+ if ((ksc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
return EINVAL;
- bcopy(&sc.sc_frame, tf, sizeof *tf);
- p->p_sigmask = sc.sc_mask & ~sigcantmask;
+ bcopy(&ksc.sc_frame, tf, sizeof *tf);
+ p->p_sigmask = ksc.sc_mask & ~sigcantmask;
return EJUSTRETURN;
}
diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c
index ae173487e9d..0d7b876a7ab 100644
--- a/sys/arch/sparc/sparc/machdep.c
+++ b/sys/arch/sparc/sparc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.177 2016/05/11 20:21:26 phessler Exp $ */
+/* $OpenBSD: machdep.c,v 1.178 2016/05/21 00:56:44 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */
/*
@@ -362,12 +362,8 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
* Send an interrupt to process.
*/
void
-sendsig(catcher, sig, mask, code, type, val)
- sig_t catcher;
- int sig, mask;
- u_long code;
- int type;
- union sigval val;
+sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
+ union sigval val)
{
struct proc *p = curproc;
struct sigacts *psp = p->p_p->ps_sigacts;
@@ -391,11 +387,6 @@ sendsig(catcher, sig, mask, code, type, val)
fp = (struct sigframe *)oldsp;
fp = (struct sigframe *)((int)(fp - 1) & ~7);
-#ifdef DEBUG
- if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
- printf("sendsig: %s[%d] sig %d newusp %p scp %p\n",
- p->p_comm, p->p_pid, sig, fp, &fp->sf_sc);
-#endif
/*
* Now set up the signal frame. We build it in kernel space
* and then copy it out. We probably ought to just build it
@@ -440,18 +431,10 @@ sendsig(catcher, sig, mask, code, type, val)
* Process has trashed its stack; give it an illegal
* instruction to halt it in its tracks.
*/
-#ifdef DEBUG
- if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
- printf("sendsig: window save or copyout error\n");
-#endif
sigexit(p, SIGILL);
/* NOTREACHED */
}
-#ifdef DEBUG
- if (sigdebug & SDB_FOLLOW)
- printf("sendsig: %s[%d] sig %d scp %p\n",
- p->p_comm, p->p_pid, sig, &fp->sf_sc);
-#endif
+
/*
* Arrange to continue execution at the code copied out in exec().
* It needs the function to call in %g1, and a new stack pointer.
@@ -461,10 +444,6 @@ sendsig(catcher, sig, mask, code, type, val)
tf->tf_pc = caddr;
tf->tf_npc = caddr + 4;
tf->tf_out[6] = newsp;
-#ifdef DEBUG
- if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
- printf("sendsig: about to return to catcher\n");
-#endif
}
/*
@@ -478,15 +457,12 @@ sendsig(catcher, sig, mask, code, type, val)
*/
/* ARGSUSED */
int
-sys_sigreturn(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
+sys_sigreturn(struct proc *p, void *v, register_t *retval)
{
struct sys_sigreturn_args /* {
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
- struct sigcontext ksc, *sc = SCARG(uap, sigcntxp);
+ struct sigcontext ksc, *scp = SCARG(uap, sigcntxp);
struct trapframe *tf;
int error;
@@ -494,34 +470,24 @@ sys_sigreturn(p, v, retval)
write_user_windows();
if (rwindow_save(p))
sigexit(p, SIGILL);
-#ifdef DEBUG
- if (sigdebug & SDB_FOLLOW)
- printf("sigreturn: %s[%d], sigcntxp %p\n",
- p->p_comm, p->p_pid, SCARG(uap, sigcntxp));
-#endif
+
if (PROC_PC(p) != p->p_p->ps_sigcoderet) {
- printf("%s(%d): sigreturn not from tramp [pc 0x%x 0x%lx]\n",
- p->p_comm, p->p_pid, PROC_PC(p), p->p_p->ps_sigcoderet);
sigexit(p, SIGILL);
return (EPERM);
}
- if ((error = copyin(sc, &ksc, sizeof(ksc))) != 0)
+ if ((error = copyin(scp, &ksc, sizeof(ksc))) != 0)
return (error);
- if (ksc.sc_cookie != ((long)sc ^ p->p_p->ps_sigcookie)) {
- printf("%s(%d): cookie %lx should have been %lx\n",
- p->p_comm, p->p_pid, ksc.sc_cookie,
- (long)sc ^ p->p_p->ps_sigcookie);
+ if (ksc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) {
sigexit(p, SIGILL);
return (EFAULT);
}
/* Prevent reuse of the sigcontext cookie */
ksc.sc_cookie = 0;
- (void)copyout(&ksc.sc_cookie, (caddr_t)sc +
- offsetof(struct sigcontext, sc_cookie),
- sizeof (ksc.sc_cookie));
+ (void)copyout(&ksc.sc_cookie, (caddr_t)scp +
+ offsetof(struct sigcontext, sc_cookie), sizeof (ksc.sc_cookie));
tf = p->p_md.md_tf;
/*