summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2003-08-01 18:37:26 +0000
committermiod <miod@openbsd.org>2003-08-01 18:37:26 +0000
commit50d10adda55beb54203e01a4e24da7c8b167c8ec (patch)
treeac559c8e85600f6102b8414a599119c113ca91ff
parentsync (diff)
downloadwireguard-openbsd-50d10adda55beb54203e01a4e24da7c8b167c8ec.tar.xz
wireguard-openbsd-50d10adda55beb54203e01a4e24da7c8b167c8ec.zip
Nuke calls to uvm_useracc() and instead check copyin() and copyout() for
failure, since the former is not reliable; requested by art@ long ago.
-rw-r--r--sys/arch/hp300/hp300/hpux_machdep.c42
-rw-r--r--sys/arch/m68k/m68k/sig_machdep.c43
-rw-r--r--sys/arch/m68k/m68k/sunos_machdep.c37
-rw-r--r--sys/arch/mvme68k/mvme68k/hpux_machdep.c42
4 files changed, 75 insertions, 89 deletions
diff --git a/sys/arch/hp300/hp300/hpux_machdep.c b/sys/arch/hp300/hp300/hpux_machdep.c
index 9e3e145ac6d..bf41b30c481 100644
--- a/sys/arch/hp300/hp300/hpux_machdep.c
+++ b/sys/arch/hp300/hp300/hpux_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hpux_machdep.c,v 1.16 2003/06/04 22:08:14 deraadt Exp $ */
+/* $OpenBSD: hpux_machdep.c,v 1.17 2003/08/01 18:37:26 miod Exp $ */
/* $NetBSD: hpux_machdep.c,v 1.19 1998/02/16 20:58:30 thorpej Exp $ */
/*
@@ -419,24 +419,6 @@ hpux_sendsig(catcher, sig, mask, code, type, val)
p->p_pid, sig, &oonstack, fp, &fp->hsf_sc, ft);
#endif
- if (uvm_useracc((caddr_t)fp, fsize, B_WRITE) == 0) {
-#ifdef DEBUG
- if ((hpuxsigdebug & SDB_KSTACK) && p->p_pid == hpuxsigpid)
- printf("hpux_sendsig(%d): useracc 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.
- */
- SIGACTION(p, SIGILL) = SIG_DFL;
- sig = sigmask(SIGILL);
- p->p_sigignore &= ~sig;
- p->p_sigcatch &= ~sig;
- p->p_sigmask &= ~sig;
- psignal(p, SIGILL);
- return;
- }
kfp = (struct hpuxsigframe *)malloc((u_long)fsize, M_TEMP, M_WAITOK);
/*
@@ -514,7 +496,24 @@ hpux_sendsig(catcher, sig, mask, code, type, val)
kfp->hsf_sc._hsc_pad = 0;
kfp->hsf_sc._hsc_ap = (int)&fp->hsf_sigstate;
- (void) copyout((caddr_t)kfp, (caddr_t)fp, fsize);
+ if (copyout((caddr_t)kfp, (caddr_t)fp, fsize) != 0) {
+#ifdef DEBUG
+ if ((hpuxsigdebug & SDB_KSTACK) && p->p_pid == hpuxsigpid)
+ printf("hpux_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.
+ */
+ SIGACTION(p, SIGILL) = SIG_DFL;
+ sig = sigmask(SIGILL);
+ p->p_sigignore &= ~sig;
+ p->p_sigcatch &= ~sig;
+ p->p_sigmask &= ~sig;
+ psignal(p, SIGILL);
+ return;
+ }
frame->f_regs[SP] = (int)fp;
#ifdef DEBUG
@@ -577,8 +576,7 @@ hpux_sys_sigreturn(p, v, retval)
* Fetch and test the HP-UX context structure.
* We grab it all at once for speed.
*/
- if (uvm_useracc((caddr_t)scp, sizeof (*scp), B_WRITE) == 0 ||
- copyin((caddr_t)scp, (caddr_t)&tsigc, sizeof tsigc))
+ if (copyin((caddr_t)scp, (caddr_t)&tsigc, sizeof tsigc))
return (EINVAL);
scp = &tsigc;
if ((scp->hsc_ps & (PSL_MBZ|PSL_IPL|PSL_S)) != 0)
diff --git a/sys/arch/m68k/m68k/sig_machdep.c b/sys/arch/m68k/m68k/sig_machdep.c
index 6943878e3c7..eb8aa5bb1c2 100644
--- a/sys/arch/m68k/m68k/sig_machdep.c
+++ b/sys/arch/m68k/m68k/sig_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sig_machdep.c,v 1.13 2003/06/02 23:27:48 millert Exp $ */
+/* $OpenBSD: sig_machdep.c,v 1.14 2003/08/01 18:37:28 miod Exp $ */
/* $NetBSD: sig_machdep.c,v 1.3 1997/04/30 23:28:03 gwr Exp $ */
/*
@@ -162,24 +162,6 @@ sendsig(catcher, sig, mask, code, type, val)
printf("sendsig(%d): sig %d ssp %p usp %p scp %p ft %d\n",
p->p_pid, sig, &oonstack, fp, &fp->sf_sc, ft);
#endif
- if (uvm_useracc((caddr_t)fp, fsize, B_WRITE) == 0) {
-#ifdef DEBUG
- if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
- printf("sendsig(%d): useracc 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.
- */
- SIGACTION(p, SIGILL) = SIG_DFL;
- sig = sigmask(SIGILL);
- p->p_sigignore &= ~sig;
- p->p_sigcatch &= ~sig;
- p->p_sigmask &= ~sig;
- psignal(p, SIGILL);
- return;
- }
kfp = (struct sigframe *)malloc((u_long)fsize, M_TEMP, M_WAITOK);
/*
* Build the argument list for the signal handler.
@@ -254,7 +236,25 @@ sendsig(catcher, sig, mask, code, type, val)
}
/* XXX do not copy out siginfo if not needed */
- (void) copyout((caddr_t)kfp, (caddr_t)fp, fsize);
+ if (copyout((caddr_t)kfp, (caddr_t)fp, fsize) != 0) {
+#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.
+ */
+ SIGACTION(p, SIGILL) = SIG_DFL;
+ sig = sigmask(SIGILL);
+ p->p_sigignore &= ~sig;
+ p->p_sigcatch &= ~sig;
+ p->p_sigmask &= ~sig;
+ psignal(p, SIGILL);
+ free((caddr_t)kfp, M_TEMP);
+ return;
+ }
frame->f_regs[SP] = (int)fp;
#ifdef DEBUG
if (sigdebug & SDB_FOLLOW)
@@ -312,8 +312,7 @@ sys_sigreturn(p, v, retval)
* Test and fetch the context structure.
* We grab it all at once for speed.
*/
- if (uvm_useracc((caddr_t)scp, sizeof (*scp), B_WRITE) == 0 ||
- copyin((caddr_t)scp, (caddr_t)&tsigc, sizeof tsigc))
+ if (copyin((caddr_t)scp, (caddr_t)&tsigc, sizeof tsigc))
return (EINVAL);
scp = &tsigc;
if ((scp->sc_ps & (PSL_MBZ|PSL_IPL|PSL_S)) != 0)
diff --git a/sys/arch/m68k/m68k/sunos_machdep.c b/sys/arch/m68k/m68k/sunos_machdep.c
index 2439694d7cb..18a8874fed9 100644
--- a/sys/arch/m68k/m68k/sunos_machdep.c
+++ b/sys/arch/m68k/m68k/sunos_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sunos_machdep.c,v 1.15 2003/06/02 23:27:48 millert Exp $ */
+/* $OpenBSD: sunos_machdep.c,v 1.16 2003/08/01 18:37:28 miod Exp $ */
/* $NetBSD: sunos_machdep.c,v 1.12 1996/10/13 03:19:22 christos Exp $ */
/*
@@ -146,24 +146,6 @@ sunos_sendsig(catcher, sig, mask, code, type, val)
printf("sunos_sendsig(%d): sig %d ssp %p usp %p scp %p ft %d\n",
p->p_pid, sig, &oonstack, fp, &fp->sf_sc, ft);
#endif
- if (uvm_useracc((caddr_t)fp, fsize, B_WRITE) == 0) {
-#ifdef DEBUG
- if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
- printf("sunos_sendsig(%d): useracc 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.
- */
- SIGACTION(p, SIGILL) = SIG_DFL;
- sig = sigmask(SIGILL);
- p->p_sigignore &= ~sig;
- p->p_sigcatch &= ~sig;
- p->p_sigmask &= ~sig;
- psignal(p, SIGILL);
- return;
- }
/*
* Build the argument list for the signal handler.
*/
@@ -182,12 +164,22 @@ sunos_sendsig(catcher, sig, mask, code, type, val)
kfp.sf_sc.sc_ps = frame->f_sr;
if (copyout(&kfp, fp, fsize) != 0) {
+#ifdef DEBUG
+ if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
+ printf("sunos_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.
*/
- sigexit(p, SIGILL);
- /* NOTREACHED */
+ SIGACTION(p, SIGILL) = SIG_DFL;
+ sig = sigmask(SIGILL);
+ p->p_sigignore &= ~sig;
+ p->p_sigcatch &= ~sig;
+ p->p_sigmask &= ~sig;
+ psignal(p, SIGILL);
+ return;
}
frame->f_regs[SP] = (int)fp;
@@ -240,8 +232,7 @@ sunos_sys_sigreturn(p, v, retval)
* Test and fetch the context structure.
* We grab it all at once for speed.
*/
- if (uvm_useracc((caddr_t)scp, sizeof(*scp), B_WRITE) == 0 ||
- copyin((caddr_t)scp, (caddr_t)&tsigc, sizeof(tsigc)))
+ if (copyin((caddr_t)scp, (caddr_t)&tsigc, sizeof(tsigc)))
return (EINVAL);
scp = &tsigc;
if ((scp->sc_ps & (PSL_MBZ|PSL_IPL|PSL_S)) != 0)
diff --git a/sys/arch/mvme68k/mvme68k/hpux_machdep.c b/sys/arch/mvme68k/mvme68k/hpux_machdep.c
index 32af6a5f1f4..612b7a1c92b 100644
--- a/sys/arch/mvme68k/mvme68k/hpux_machdep.c
+++ b/sys/arch/mvme68k/mvme68k/hpux_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hpux_machdep.c,v 1.11 2003/06/04 22:08:16 deraadt Exp $ */
+/* $OpenBSD: hpux_machdep.c,v 1.12 2003/08/01 18:37:28 miod Exp $ */
/* $NetBSD: hpux_machdep.c,v 1.9 1997/03/16 10:00:45 thorpej Exp $ */
/*
@@ -458,24 +458,6 @@ hpux_sendsig(catcher, sig, mask, code, type, val)
p->p_pid, sig, &oonstack, fp, &fp->sf_sc, ft);
#endif
- if (uvm_useracc((caddr_t)fp, fsize, B_WRITE) == 0) {
-#ifdef DEBUG
- if ((hpuxsigdebug & SDB_KSTACK) && p->p_pid == hpuxsigpid)
- printf("hpux_sendsig(%d): useracc 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.
- */
- SIGACTION(p, SIGILL) = SIG_DFL;
- sig = sigmask(SIGILL);
- p->p_sigignore &= ~sig;
- p->p_sigcatch &= ~sig;
- p->p_sigmask &= ~sig;
- psignal(p, SIGILL);
- return;
- }
kfp = (struct hpuxsigframe *)malloc((u_long)fsize, M_TEMP, M_WAITOK);
/*
@@ -552,7 +534,24 @@ hpux_sendsig(catcher, sig, mask, code, type, val)
kfp->hsf_sc._hsc_pad = 0;
kfp->hsf_sc._hsc_ap = (int)&fp->hsf_sigstate;
- (void) copyout((caddr_t)kfp, (caddr_t)fp, fsize);
+ if (copyout((caddr_t)kfp, (caddr_t)fp, fsize) != 0) {
+#ifdef DEBUG
+ if ((hpuxsigdebug & SDB_KSTACK) && p->p_pid == hpuxsigpid)
+ printf("hpux_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.
+ */
+ SIGACTION(p, SIGILL) = SIG_DFL;
+ sig = sigmask(SIGILL);
+ p->p_sigignore &= ~sig;
+ p->p_sigcatch &= ~sig;
+ p->p_sigmask &= ~sig;
+ psignal(p, SIGILL);
+ return;
+ }
frame->f_regs[SP] = (int)fp;
#ifdef DEBUG
@@ -615,8 +614,7 @@ hpux_sys_sigreturn(p, v, retval)
* Fetch and test the HP-UX context structure.
* We grab it all at once for speed.
*/
- if (uvm_useracc((caddr_t)scp, sizeof (*scp), B_WRITE) == 0 ||
- copyin((caddr_t)scp, (caddr_t)&tsigc, sizeof tsigc))
+ if (copyin((caddr_t)scp, (caddr_t)&tsigc, sizeof tsigc))
return (EINVAL);
scp = &tsigc;
if ((scp->hsc_ps & (PSL_MBZ|PSL_IPL|PSL_S)) != 0)