From aa4d062142bc39b8574313bb8e24c70b48a44bca Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 5 Apr 2002 00:52:15 +0000 Subject: [PATCH] o Eliminate the use of grow_stack() and useracc() from sendsig(), osendsig(), and osf1_sendsig(). o Eliminate the prototype for the MD grow_stack() now that it has been removed from all platforms. --- sys/alpha/alpha/machdep.c | 68 ++++++++++++++++-------------------- sys/alpha/alpha/vm_machdep.c | 15 -------- sys/alpha/osf1/osf1_signal.c | 29 +++++++-------- sys/vm/vm_extern.h | 1 - 4 files changed, 44 insertions(+), 69 deletions(-) diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index a8b1abf6ce8b..2b8f8b5c4745 100644 --- a/sys/alpha/alpha/machdep.c +++ b/sys/alpha/alpha/machdep.c @@ -1204,21 +1204,6 @@ osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) sip = (osiginfo_t *)(alpha_pal_rdusp() - rndfsize); PROC_UNLOCK(p); - (void)grow_stack(p, (u_long)sip); - if (!useracc((caddr_t)sip, fsize, VM_PROT_WRITE)) { - /* - * Process has trashed its stack; give it an illegal - * instruction to halt it in its tracks. - */ - PROC_LOCK(p); - SIGACTION(p, SIGILL) = SIG_DFL; - SIGDELSET(p->p_sigignore, SIGILL); - SIGDELSET(p->p_sigcatch, SIGILL); - SIGDELSET(p->p_sigmask, SIGILL); - psignal(p, SIGILL); - return; - } - /* * Build the signal context to be used by sigreturn. */ @@ -1255,7 +1240,19 @@ osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) /* * copy the frame out to userland. */ - (void) copyout((caddr_t)&ksi, (caddr_t)sip, fsize); + if (copyout((caddr_t)&ksi, (caddr_t)sip, fsize) != 0) { + /* + * Process has trashed its stack; give it an illegal + * instruction to halt it in its tracks. + */ + PROC_LOCK(p); + SIGACTION(p, SIGILL) = SIG_DFL; + SIGDELSET(p->p_sigignore, SIGILL); + SIGDELSET(p->p_sigcatch, SIGILL); + SIGDELSET(p->p_sigmask, SIGILL); + psignal(p, SIGILL); + return; + } /* * Set up the registers to return to sigcode. @@ -1338,31 +1335,11 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) sfp = (struct sigframe *)(alpha_pal_rdusp() - rndfsize); PROC_UNLOCK(p); - (void)grow_stack(p, (u_long)sfp); #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) printf("sendsig(%d): sig %d ssp %p usp %p\n", p->p_pid, sig, &sf, sfp); #endif - if (!useracc((caddr_t)sfp, sizeof(sf), VM_PROT_WRITE)) { -#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. - */ - PROC_LOCK(p); - SIGACTION(p, SIGILL) = SIG_DFL; - SIGDELSET(p->p_sigignore, SIGILL); - SIGDELSET(p->p_sigcatch, SIGILL); - SIGDELSET(p->p_sigmask, SIGILL); - psignal(p, SIGILL); - return; - } - /* save the floating-point state, if necessary, then copy it. */ alpha_fpstate_save(td, 1); sf.sf_uc.uc_mcontext.mc_ownedfp = td->td_md.md_flags & MDP_FPUSED; @@ -1380,7 +1357,24 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) /* * copy the frame out to userland. */ - (void) copyout((caddr_t)&sf, (caddr_t)sfp, sizeof(sf)); + if (copyout((caddr_t)&sf, (caddr_t)sfp, sizeof(sf)) != 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. + */ + PROC_LOCK(p); + SIGACTION(p, SIGILL) = SIG_DFL; + SIGDELSET(p->p_sigignore, SIGILL); + SIGDELSET(p->p_sigcatch, SIGILL); + SIGDELSET(p->p_sigmask, SIGILL); + psignal(p, SIGILL); + return; + } #ifdef DEBUG if (sigdebug & SDB_FOLLOW) printf("sendsig(%d): sig %d sfp %p code %lx\n", p->p_pid, sig, diff --git a/sys/alpha/alpha/vm_machdep.c b/sys/alpha/alpha/vm_machdep.c index 467f4fa57250..4209cce55a96 100644 --- a/sys/alpha/alpha/vm_machdep.c +++ b/sys/alpha/alpha/vm_machdep.c @@ -352,21 +352,6 @@ cpu_reset() prom_halt(0); } -int -grow_stack(p, sp) - struct proc *p; - size_t sp; -{ - int rv; - - rv = vm_map_growstack (p, sp); - if (rv != KERN_SUCCESS) - return (0); - - return (1); -} - - /* * Software interrupt handler for queued VM system processing. */ diff --git a/sys/alpha/osf1/osf1_signal.c b/sys/alpha/osf1/osf1_signal.c index 61803e7b6150..67ae47d3526d 100644 --- a/sys/alpha/osf1/osf1_signal.c +++ b/sys/alpha/osf1/osf1_signal.c @@ -616,21 +616,6 @@ osf1_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) sip = (osiginfo_t *)(alpha_pal_rdusp() - rndfsize); PROC_UNLOCK(p); - (void)grow_stack(p, (u_long)sip); - if (useracc((caddr_t)sip, fsize, VM_PROT_WRITE) == 0) { - /* - * Process has trashed its stack; give it an illegal - * instruction to halt it in its tracks. - */ - PROC_LOCK(p); - SIGACTION(p, SIGILL) = SIG_DFL; - SIGDELSET(p->p_sigignore, SIGILL); - SIGDELSET(p->p_sigcatch, SIGILL); - SIGDELSET(p->p_sigmask, SIGILL); - psignal(p, SIGILL); - return; - } - /* * Build the signal context to be used by sigreturn. */ @@ -667,7 +652,19 @@ osf1_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) /* * copy the frame out to userland. */ - (void) copyout((caddr_t)&ksi, (caddr_t)sip, fsize); + if (copyout((caddr_t)&ksi, (caddr_t)sip, fsize) != 0) { + /* + * Process has trashed its stack; give it an illegal + * instruction to halt it in its tracks. + */ + PROC_LOCK(p); + SIGACTION(p, SIGILL) = SIG_DFL; + SIGDELSET(p->p_sigignore, SIGILL); + SIGDELSET(p->p_sigcatch, SIGILL); + SIGDELSET(p->p_sigmask, SIGILL); + psignal(p, SIGILL); + return; + } /* * Set up the registers to return to sigcode. diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index da72708684d0..b84132979aba 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -59,7 +59,6 @@ int sstk(struct thread *, void *, int *); int swapon(struct thread *, void *, int *); #endif /* TYPEDEF_FOR_UAP */ -int grow_stack(struct proc *, size_t); int kernacc(caddr_t, int, int); vm_offset_t kmem_alloc(vm_map_t, vm_size_t); vm_offset_t kmem_alloc_nofault(vm_map_t, vm_size_t);