diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-04-18 21:44:57 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-04-18 21:44:57 +0000 |
commit | bce64c2a24fb4484b18813bef367dcc71e8a0dd0 (patch) | |
tree | dfc7f71507d6c603255802772ca128609460ca08 /sys | |
parent | fd1b35e57ce1fdce5ec1dc979ff36b7649cab0c5 (diff) |
Revert the sigacts diff: NFS can apparently retain pointers to processes
until they're zombies and then send them signals (for intr mounts). Until
that is untangled, the sigacts change is unsafe. sthen@ was the victim
for this one
Diffstat (limited to 'sys')
37 files changed, 321 insertions, 316 deletions
diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c index f7c6c247463..ebdd78a680f 100644 --- a/sys/arch/alpha/alpha/machdep.c +++ b/sys/arch/alpha/alpha/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.129 2011/04/15 04:52:39 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.130 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.210 2000/06/01 17:12:38 thorpej Exp $ */ /*- @@ -1437,7 +1437,7 @@ sendsig(catcher, sig, mask, code, type, val) siginfo_t *sip, ksi; frame = p->p_md.md_tf; - oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; fsize = sizeof ksc; rndfsize = ((fsize + 15) / 16) * 16; kscsize = rndfsize; @@ -1453,11 +1453,11 @@ sendsig(catcher, sig, mask, code, type, val) * will fail if the process has not already allocated * the space with a `brk'. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - scp = (struct sigcontext *)(p->p_sigstk.ss_sp + - p->p_sigstk.ss_size - rndfsize); - p->p_sigstk.ss_flags |= SS_ONSTACK; + scp = (struct sigcontext *)(psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size - rndfsize); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else scp = (struct sigcontext *)(alpha_pal_rdusp() - rndfsize); if ((u_long)scp <= USRSTACK - ptoa(p->p_vmspace->vm_ssize)) @@ -1590,9 +1590,9 @@ sys_sigreturn(p, v, retval) * Restore the user-supplied information */ if (ksc.sc_onstack) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = ksc.sc_mask &~ sigcantmask; p->p_md.md_tf->tf_regs[FRAME_PC] = ksc.sc_pc; diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 94cb7ba1ac4..3e4c0ab6a4c 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.139 2011/04/17 20:38:09 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.140 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -553,15 +553,15 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type, #endif bcopy(tf, &ksc, sizeof(*tf)); - ksc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK; + ksc.sc_onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; ksc.sc_mask = mask; ksc.sc_fpstate = NULL; /* Allocate space for the signal handler context. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !ksc.sc_onstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !ksc.sc_onstack && (psp->ps_sigonstack & sigmask(sig))) { - sp = (register_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size; - p->p_sigstk.ss_flags |= SS_ONSTACK; + sp = (register_t)psp->ps_sigstk.ss_sp + psp->ps_sigstk.ss_size; + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else sp = tf->tf_rsp - 128; @@ -670,9 +670,9 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) /* Restore signal stack. */ if (ksc.sc_onstack) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = ksc.sc_mask & ~sigcantmask; return (EJUSTRETURN); diff --git a/sys/arch/arm/arm/sig_machdep.c b/sys/arch/arm/arm/sig_machdep.c index fb6447e89c4..7181b17b47c 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.4 2011/04/16 02:34:19 deraadt Exp $ */ +/* $OpenBSD: sig_machdep.c,v 1.5 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: sig_machdep.c,v 1.22 2003/10/08 00:28:41 thorpej Exp $ */ /* @@ -87,7 +87,7 @@ sendsig(sig_t catcher, int sig, int returnmask, u_long code, int type, struct trapframe *tf; struct sigframe *fp, frame; struct sigacts *psp = p->p_sigacts; - int oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + int oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; int onstack = 0; tf = process_frame(p); @@ -95,11 +95,11 @@ sendsig(sig_t catcher, int sig, int returnmask, u_long code, int type, /* Do we need to jump onto the signal stack? */ /* Allocate space for the signal handler context. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { onstack = 1; - fp = (struct sigframe *)((caddr_t)p->p_sigstk.ss_sp + - p->p_sigstk.ss_size); + fp = (struct sigframe *)((caddr_t)psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size); } else fp = (struct sigframe *)tf->tf_usr_sp; /* make room on the stack */ @@ -135,7 +135,7 @@ sendsig(sig_t catcher, int sig, int returnmask, u_long code, int type, frame.sf_sc.sc_spsr = tf->tf_spsr; /* Save signal stack. */ - frame.sf_sc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK; + frame.sf_sc.sc_onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* Save signal mask. */ frame.sf_sc.sc_mask = returnmask; @@ -177,7 +177,7 @@ sendsig(sig_t catcher, int sig, int returnmask, u_long code, int type, /* Remember that we're now on the signal stack. */ if (onstack) - p->p_sigstk.ss_flags |= SS_ONSTACK; + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } #if 0 @@ -216,6 +216,7 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) } */ *uap = v; struct sigcontext *scp, context; struct trapframe *tf; + struct sigacts *psp = p->p_sigacts; /* * we do a rather scary test in userland @@ -269,9 +270,9 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) /* Restore signal stack. */ if (context.sc_onstack & SS_ONSTACK) - p->p_sigstk.ss_flags |= SS_ONSTACK; + psp->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + psp->ps_sigstk.ss_flags &= ~SS_ONSTACK; /* Restore signal mask. */ #if 0 diff --git a/sys/arch/hp300/hp300/trap.c b/sys/arch/hp300/hp300/trap.c index 17e47f69ad9..da405ea6980 100644 --- a/sys/arch/hp300/hp300/trap.c +++ b/sys/arch/hp300/hp300/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.57 2011/04/15 04:52:39 guenther Exp $ */ +/* $OpenBSD: trap.c,v 1.58 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: trap.c,v 1.57 1998/02/16 20:58:31 thorpej Exp $ */ /* @@ -347,8 +347,8 @@ dopanic: type |= T_USER; p->p_sigacts->ps_sigact[SIGILL] = SIG_DFL; i = sigmask(SIGILL); - p->p_sigacts->ps_sigignore &= ~i; - p->p_sigacts->ps_sigcatch &= ~i; + p->p_sigignore &= ~i; + p->p_sigcatch &= ~i; p->p_sigmask &= ~i; i = SIGILL; ucode = frame.f_format; /* XXX was ILL_RESAD_FAULT */ diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c index f2876895b98..332dd8deaec 100644 --- a/sys/arch/hppa/hppa/machdep.c +++ b/sys/arch/hppa/hppa/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.200 2011/04/15 04:52:39 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.201 2011/04/18 21:44:55 guenther Exp $ */ /* * Copyright (c) 1999-2003 Michael Shalayeff @@ -1199,15 +1199,15 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type, /* Save the FPU context first. */ fpu_proc_save(p); - ksc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK; + ksc.sc_onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Allocate space for the signal handler context. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !ksc.sc_onstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !ksc.sc_onstack && (psp->ps_sigonstack & sigmask(sig))) { - scp = (register_t)p->p_sigstk.ss_sp; - p->p_sigstk.ss_flags |= SS_ONSTACK; + scp = (register_t)psp->ps_sigstk.ss_sp; + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else scp = (tf->tf_sp + 63) & ~63; @@ -1331,9 +1331,9 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) return (EINVAL); if (ksc.sc_onstack) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = ksc.sc_mask &~ sigcantmask; tf->tf_t1 = ksc.sc_regs[0]; /* r22 */ diff --git a/sys/arch/hppa64/hppa64/machdep.c b/sys/arch/hppa64/hppa64/machdep.c index bb74672a866..35cf9a595d6 100644 --- a/sys/arch/hppa64/hppa64/machdep.c +++ b/sys/arch/hppa64/hppa64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.35 2011/04/16 22:02:32 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.36 2011/04/18 21:44:55 guenther Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -854,15 +854,15 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type, /* Save the FPU context first. */ fpu_proc_save(p); - ksc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK; + ksc.sc_onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Allocate space for the signal handler context. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !ksc.sc_onstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !ksc.sc_onstack && (psp->ps_sigonstack & sigmask(sig))) { - scp = (register_t)p->p_sigstk.ss_sp; - p->p_sigstk.ss_flags |= SS_ONSTACK; + scp = (register_t)psp->ps_sigstk.ss_sp; + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else scp = (tf->tf_sp + 63) & ~63; @@ -957,9 +957,9 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) return (EINVAL); if (ksc.sc_onstack) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = ksc.sc_mask &~ sigcantmask; tf->tf_sar = ksc.sc_regs[0]; diff --git a/sys/arch/i386/i386/linux_machdep.c b/sys/arch/i386/i386/linux_machdep.c index 63694f4fea5..1363e747c50 100644 --- a/sys/arch/i386/i386/linux_machdep.c +++ b/sys/arch/i386/i386/linux_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_machdep.c,v 1.38 2011/04/15 04:52:39 guenther Exp $ */ +/* $OpenBSD: linux_machdep.c,v 1.39 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: linux_machdep.c,v 1.29 1996/05/03 19:42:11 christos Exp $ */ /* @@ -114,16 +114,16 @@ linux_sendsig(sig_t catcher, int sig, int mask, u_long code, int type, int oonstack; tf = p->p_md.md_regs; - oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Allocate space for the signal handler context. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct linux_sigframe *)((char *)p->p_sigstk.ss_sp + - p->p_sigstk.ss_size - sizeof(struct linux_sigframe)); - p->p_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct linux_sigframe *)((char *)psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size - sizeof(struct linux_sigframe)); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else { fp = (struct linux_sigframe *)tf->tf_esp - 1; } @@ -257,7 +257,7 @@ linux_sys_sigreturn(struct proc *p, void *v, register_t *retval) tf->tf_esp = context.sc_esp_at_signal; tf->tf_ss = context.sc_ss; - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = context.sc_mask & ~sigcantmask; return (EJUSTRETURN); diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 0700d4fdc87..86706325691 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.491 2011/04/16 00:40:58 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.492 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -2189,7 +2189,7 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type, struct sigframe *fp, frame; struct sigacts *psp = p->p_sigacts; register_t sp; - int oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + int oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Build the argument list for the signal handler. @@ -2199,10 +2199,10 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type, /* * Allocate space for the signal handler context. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - sp = (long)p->p_sigstk.ss_sp + p->p_sigstk.ss_size; - p->p_sigstk.ss_flags |= SS_ONSTACK; + sp = (long)psp->ps_sigstk.ss_sp + psp->ps_sigstk.ss_size; + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else sp = tf->tf_esp; @@ -2377,9 +2377,9 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) } if (context.sc_onstack & 01) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = context.sc_mask & ~sigcantmask; return (EJUSTRETURN); diff --git a/sys/arch/i386/i386/svr4_machdep.c b/sys/arch/i386/i386/svr4_machdep.c index 80a363e5f50..dd53247a300 100644 --- a/sys/arch/i386/i386/svr4_machdep.c +++ b/sys/arch/i386/i386/svr4_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_machdep.c,v 1.28 2011/04/15 10:03:44 claudio Exp $ */ +/* $OpenBSD: svr4_machdep.c,v 1.29 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: svr4_machdep.c,v 1.24 1996/05/03 19:42:26 christos Exp $ */ /* @@ -63,9 +63,10 @@ svr4_getcontext(struct proc *p, struct svr4_ucontext *uc, int mask, int oonstack) { struct trapframe *tf = p->p_md.md_regs; + struct sigacts *psp = p->p_sigacts; svr4_greg_t *r = uc->uc_mcontext.greg; struct svr4_sigaltstack *s = &uc->uc_stack; - struct sigaltstack *sf = &p->p_sigstk; + struct sigaltstack *sf = &psp->ps_sigstk; bzero(uc, sizeof(struct svr4_ucontext)); @@ -133,10 +134,11 @@ svr4_getcontext(struct proc *p, struct svr4_ucontext *uc, int mask, int svr4_setcontext(struct proc *p, struct svr4_ucontext *uc) { + struct sigacts *psp = p->p_sigacts; struct trapframe *tf; svr4_greg_t *r = uc->uc_mcontext.greg; struct svr4_sigaltstack *s = &uc->uc_stack; - struct sigaltstack *sf = &p->p_sigstk; + struct sigaltstack *sf = &psp->ps_sigstk; int mask; /* @@ -314,16 +316,16 @@ svr4_sendsig(sig_t catcher, int sig, int mask, u_long code, int type, int oonstack; tf = p->p_md.md_regs; - oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Allocate space for the signal handler context. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct svr4_sigframe *)((char *)p->p_sigstk.ss_sp + - p->p_sigstk.ss_size - sizeof(struct svr4_sigframe)); - p->p_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct svr4_sigframe *)((char *)psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size - sizeof(struct svr4_sigframe)); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else { fp = (struct svr4_sigframe *)tf->tf_esp - 1; } diff --git a/sys/arch/i386/i386/vm86.c b/sys/arch/i386/i386/vm86.c index 8c2b1aca73e..4ca36573bf4 100644 --- a/sys/arch/i386/i386/vm86.c +++ b/sys/arch/i386/i386/vm86.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm86.c,v 1.19 2011/04/15 04:52:39 guenther Exp $ */ +/* $OpenBSD: vm86.c,v 1.20 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: vm86.c,v 1.15 1996/05/03 19:42:33 christos Exp $ */ /*- @@ -427,7 +427,7 @@ i386_vm86(struct proc *p, char *args, register_t *retval) #undef DOREG /* Going into vm86 mode jumps off the signal stack. */ - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; set_vflags(p, vm86s.regs.vmsc.sc_eflags | PSL_VM); diff --git a/sys/arch/m68k/m68k/sig_machdep.c b/sys/arch/m68k/m68k/sig_machdep.c index eedfc32ddf7..512677e856c 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.23 2011/04/15 04:52:39 guenther Exp $ */ +/* $OpenBSD: sig_machdep.c,v 1.24 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: sig_machdep.c,v 1.3 1997/04/30 23:28:03 gwr Exp $ */ /* @@ -135,7 +135,7 @@ sendsig(catcher, sig, mask, code, type, val) frame = (struct frame *)p->p_md.md_regs; ft = frame->f_format; - oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Allocate and validate space for the signal handler @@ -145,11 +145,11 @@ sendsig(catcher, sig, mask, code, type, val) * the space with a `brk'. */ fsize = sizeof(struct sigframe); - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(p->p_sigstk.ss_sp + - p->p_sigstk.ss_size - fsize); - p->p_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size - fsize); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct sigframe *)(frame->f_regs[SP] - fsize); if ((unsigned)fp <= USRSTACK - ptoa(p->p_vmspace->vm_ssize)) @@ -321,9 +321,9 @@ sys_sigreturn(p, v, retval) * Restore the user supplied information */ if (scp->sc_onstack & 1) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = scp->sc_mask &~ sigcantmask; frame = (struct frame *) p->p_md.md_regs; frame->f_regs[SP] = scp->sc_sp; diff --git a/sys/arch/m88k/m88k/sig_machdep.c b/sys/arch/m88k/m88k/sig_machdep.c index 7818639a416..49954336de8 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.11 2011/04/15 04:52:39 guenther Exp $ */ +/* $OpenBSD: sig_machdep.c,v 1.12 2011/04/18 21:44:55 guenther Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -95,7 +95,7 @@ sendsig(sig_t catcher, int sig, int mask, unsigned long code, int type, vaddr_t addr; tf = p->p_md.md_tf; - oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Allocate and validate space for the signal handler * context. Note that if the stack is in data space, the @@ -104,12 +104,12 @@ sendsig(sig_t catcher, int sig, int mask, unsigned long code, int type, * the space with a `brk'. */ fsize = sizeof(struct sigframe); - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && - (p->p_sigstk.ss_flags & SS_ONSTACK) == 0 && + if ((psp->ps_flags & SAS_ALTSTACK) && + (psp->ps_sigstk.ss_flags & SS_ONSTACK) == 0 && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(p->p_sigstk.ss_sp + - p->p_sigstk.ss_size - fsize); - p->p_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size - fsize); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct sigframe *)(tf->tf_r[31] - fsize); @@ -222,9 +222,9 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) * Restore the user supplied information */ if (scp->sc_onstack & SS_ONSTACK) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = scp->sc_mask & ~sigcantmask; /* diff --git a/sys/arch/mac68k/mac68k/trap.c b/sys/arch/mac68k/mac68k/trap.c index 42c089aba69..b3706c715b8 100644 --- a/sys/arch/mac68k/mac68k/trap.c +++ b/sys/arch/mac68k/mac68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.58 2011/04/15 04:52:39 guenther Exp $ */ +/* $OpenBSD: trap.c,v 1.59 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: trap.c,v 1.68 1998/12/22 08:47:07 scottr Exp $ */ /* @@ -402,8 +402,8 @@ copyfault: type |= T_USER; p->p_sigacts->ps_sigact[SIGILL] = SIG_DFL; i = sigmask(SIGILL); - p->p_sigacts->ps_sigignore &= ~i; - p->p_sigacts->ps_sigcatch &= ~i; + p->p_sigignore &= ~i; + p->p_sigcatch &= ~i; p->p_sigmask &= ~i; i = SIGILL; ucode = frame.f_format; /* XXX was ILL_RESAD_FAULT */ diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c index 78da19010bc..cfcd9e317de 100644 --- a/sys/arch/macppc/macppc/machdep.c +++ b/sys/arch/macppc/macppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.125 2011/04/15 20:52:57 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.126 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -576,17 +576,17 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type, frame.sf_signum = sig; tf = trapframe(p); - oldonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + oldonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Allocate stack space for signal handler. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 + if ((psp->ps_flags & SAS_ALTSTACK) && !oldonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(p->p_sigstk.ss_sp - + p->p_sigstk.ss_size); - p->p_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct sigframe *)tf->fixreg[1]; @@ -642,9 +642,9 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) return EINVAL; bcopy(&sc.sc_frame, tf, sizeof *tf); if (sc.sc_onstack & 1) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = sc.sc_mask & ~sigcantmask; return EJUSTRETURN; } diff --git a/sys/arch/mips64/mips64/sendsig.c b/sys/arch/mips64/mips64/sendsig.c index 117b484677b..222fbdff635 100644 --- a/sys/arch/mips64/mips64/sendsig.c +++ b/sys/arch/mips64/mips64/sendsig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sendsig.c,v 1.15 2011/04/15 04:52:39 guenther Exp $ */ +/* $OpenBSD: sendsig.c,v 1.16 2011/04/18 21:44:55 guenther Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. @@ -115,7 +115,7 @@ sendsig(catcher, sig, mask, code, type, val) struct sigcontext ksc; regs = p->p_md.md_regs; - oonstack = p->p_sigstk.ss_flags & SA_ONSTACK; + oonstack = psp->ps_sigstk.ss_flags & SA_ONSTACK; /* * Allocate and validate space for the signal handler * context. Note that if the stack is in data space, the @@ -126,12 +126,12 @@ sendsig(catcher, sig, mask, code, type, val) fsize = sizeof(struct sigframe); if (!(psp->ps_siginfo & sigmask(sig))) fsize -= sizeof(siginfo_t); - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && - (p->p_sigstk.ss_flags & SA_ONSTACK) == 0 && + if ((psp->ps_flags & SAS_ALTSTACK) && + (psp->ps_sigstk.ss_flags & SA_ONSTACK) == 0 && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(p->p_sigstk.ss_sp + - p->p_sigstk.ss_size - fsize); - p->p_sigstk.ss_flags |= SA_ONSTACK; + fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size - fsize); + psp->ps_sigstk.ss_flags |= SA_ONSTACK; } else fp = (struct sigframe *)(regs->sp - fsize); if ((vaddr_t)fp <= USRSTACK - ptoa(p->p_vmspace->vm_ssize)) @@ -255,9 +255,9 @@ sys_sigreturn(p, v, retval) * Restore the user supplied information */ if (scp->sc_onstack & SA_ONSTACK) - p->p_sigstk.ss_flags |= SA_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SA_ONSTACK; else - p->p_sigstk.ss_flags &= ~SA_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SA_ONSTACK; p->p_sigmask = scp->sc_mask &~ sigcantmask; regs->pc = scp->sc_pc; regs->mullo = scp->mullo; diff --git a/sys/arch/mvme68k/mvme68k/trap.c b/sys/arch/mvme68k/mvme68k/trap.c index 9216637bab0..cee85e6fb07 100644 --- a/sys/arch/mvme68k/mvme68k/trap.c +++ b/sys/arch/mvme68k/mvme68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.72 2011/04/15 04:52:39 guenther Exp $ */ +/* $OpenBSD: trap.c,v 1.73 2011/04/18 21:44:55 guenther Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -286,8 +286,8 @@ copyfault: type |= T_USER; p->p_sigacts->ps_sigact[SIGILL] = SIG_DFL; i = sigmask(SIGILL); - p->p_sigacts->ps_sigignore &= ~i; - p->p_sigacts->ps_sigcatch &= ~i; + p->p_sigignore &= ~i; + p->p_sigcatch &= ~i; p->p_sigmask &= ~i; i = SIGILL; ucode = frame.f_format; /* XXX was ILL_RESAD_FAULT */ diff --git a/sys/arch/mvmeppc/mvmeppc/machdep.c b/sys/arch/mvmeppc/mvmeppc/machdep.c index 754ec737d30..c85a9859dfb 100644 --- a/sys/arch/mvmeppc/mvmeppc/machdep.c +++ b/sys/arch/mvmeppc/mvmeppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.65 2011/04/15 04:52:39 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.66 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -487,17 +487,17 @@ sendsig(catcher, sig, mask, code, type, val) frame.sf_signum = sig; tf = trapframe(p); - oldonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + oldonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Allocate stack space for signal handler. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 + if ((psp->ps_flags & SAS_ALTSTACK) && !oldonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(p->p_sigstk.ss_sp - + p->p_sigstk.ss_size); - p->p_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct sigframe *)tf->fixreg[1]; @@ -554,9 +554,9 @@ sys_sigreturn(p, v, retval) return EINVAL; bcopy(&sc.sc_frame, tf, sizeof *tf); if (sc.sc_onstack & 1) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = sc.sc_mask & ~sigcantmask; return EJUSTRETURN; } diff --git a/sys/arch/sh/sh/sh_machdep.c b/sys/arch/sh/sh/sh_machdep.c index 86882ef293a..9f8137d62c4 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.28 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: sh_machdep.c,v 1.29 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: sh3_machdep.c,v 1.59 2006/03/04 01:13:36 uwe Exp $ */ /* @@ -471,16 +471,16 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type, struct proc *p = curproc; struct sigframe *fp, frame; struct trapframe *tf = p->p_md.md_regs; - struct sigacts *psp = p->p_sigacts; + struct sigacts *ps = p->p_sigacts; siginfo_t *sip; int onstack; - onstack = p->p_sigstk.ss_flags & SS_ONSTACK; - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && onstack == 0 && - (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)((vaddr_t)p->p_sigstk.ss_sp + - p->p_sigstk.ss_size); - p->p_sigstk.ss_flags |= SS_ONSTACK; + onstack = ps->ps_sigstk.ss_flags & SS_ONSTACK; + if ((ps->ps_flags & SAS_ALTSTACK) && onstack == 0 && + (ps->ps_sigonstack & sigmask(sig))) { + fp = (struct sigframe *)((vaddr_t)ps->ps_sigstk.ss_sp + + ps->ps_sigstk.ss_size); + ps->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (void *)p->p_md.md_regs->tf_r15; --fp; @@ -488,7 +488,7 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type, bzero(&frame, sizeof(frame)); - if (psp->ps_siginfo & sigmask(sig)) { + if (ps->ps_siginfo & sigmask(sig)) { initsiginfo(&frame.sf_si, sig, code, type, val); sip = &fp->sf_si; } else @@ -608,9 +608,9 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) /* Restore signal stack. */ if (context.sc_onstack) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; /* Restore signal mask. */ p->p_sigmask = context.sc_mask & ~sigcantmask; diff --git a/sys/arch/socppc/socppc/machdep.c b/sys/arch/socppc/socppc/machdep.c index 953792648e7..19e2695776d 100644 --- a/sys/arch/socppc/socppc/machdep.c +++ b/sys/arch/socppc/socppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.28 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.29 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -901,17 +901,17 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type, frame.sf_signum = sig; tf = trapframe(p); - oldonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + oldonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Allocate stack space for signal handler. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 + if ((psp->ps_flags & SAS_ALTSTACK) && !oldonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(p->p_sigstk.ss_sp - + p->p_sigstk.ss_size); - p->p_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct sigframe *)tf->fixreg[1]; @@ -965,9 +965,9 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) return EINVAL; bcopy(&sc.sc_frame, tf, sizeof *tf); if (sc.sc_onstack & 1) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = sc.sc_mask & ~sigcantmask; return EJUSTRETURN; } diff --git a/sys/arch/solbourne/solbourne/machdep.c b/sys/arch/solbourne/solbourne/machdep.c index 82b241e1b80..ef730561f65 100644 --- a/sys/arch/solbourne/solbourne/machdep.c +++ b/sys/arch/solbourne/solbourne/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.17 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.18 2011/04/18 21:44:55 guenther Exp $ */ /* OpenBSD: machdep.c,v 1.105 2005/04/11 15:13:01 deraadt Exp */ /* @@ -382,16 +382,16 @@ sendsig(catcher, sig, mask, code, type, val) tf = p->p_md.md_tf; oldsp = tf->tf_out[6]; - oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Compute new user stack addresses, subtract off * one signal frame, and align. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(p->p_sigstk.ss_sp + - p->p_sigstk.ss_size); - p->p_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct sigframe *)oldsp; fp = (struct sigframe *)((int)(fp - 1) & ~7); @@ -522,9 +522,9 @@ sys_sigreturn(p, v, retval) tf->tf_out[0] = ksc.sc_o0; tf->tf_out[6] = ksc.sc_sp; if (ksc.sc_onstack & 1) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; 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 2e1cda76f1d..3cc31de8fec 100644 --- a/sys/arch/sparc/sparc/machdep.c +++ b/sys/arch/sparc/sparc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.133 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.134 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */ /* @@ -395,16 +395,16 @@ sendsig(catcher, sig, mask, code, type, val) tf = p->p_md.md_tf; oldsp = tf->tf_out[6]; - oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Compute new user stack addresses, subtract off * one signal frame, and align. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(p->p_sigstk.ss_sp + - p->p_sigstk.ss_size); - p->p_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct sigframe *)oldsp; fp = (struct sigframe *)((int)(fp - 1) & ~7); @@ -535,9 +535,9 @@ sys_sigreturn(p, v, retval) tf->tf_out[0] = ksc.sc_o0; tf->tf_out[6] = ksc.sc_sp; if (ksc.sc_onstack & 1) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = ksc.sc_mask & ~sigcantmask; return (EJUSTRETURN); } diff --git a/sys/arch/sparc/sparc/svr4_machdep.c b/sys/arch/sparc/sparc/svr4_machdep.c index a2dde35c7fd..e1514f427fc 100644 --- a/sys/arch/sparc/sparc/svr4_machdep.c +++ b/sys/arch/sparc/sparc/svr4_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_machdep.c,v 1.16 2011/04/16 19:09:41 miod Exp $ */ +/* $OpenBSD: svr4_machdep.c,v 1.17 2011/04/18 21:44:55 guenther Exp $ */ /* $NetBSD: svr4_machdep.c,v 1.24 1997/07/29 10:04:45 fair Exp $ */ /* @@ -216,10 +216,11 @@ svr4_setcontext(p, uc) struct proc *p; struct svr4_ucontext *uc; { + struct sigacts *psp = p->p_sigacts; register struct trapframe *tf; svr4_greg_t *r = uc->uc_mcontext.greg; struct svr4_sigaltstack *s = &uc->uc_stack; - struct sigaltstack *sf = &p->p_sigstk; + struct sigaltstack *sf = &psp->ps_sigstk; int mask; #ifdef FPU_CONTEXT svr4_fregset_t *f = &uc->uc_mcontext.freg; @@ -461,16 +462,16 @@ svr4_sendsig(catcher, sig, mask, code, type, val) tf = (struct trapframe *)p->p_md.md_tf; oldsp = tf->tf_out[6]; - oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; + oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* * Allocate space for the signal handler context. */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct svr4_sigframe *)(p->p_sigstk.ss_sp + - p->p_sigstk.ss_size); - p->p_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct svr4_sigframe *)(psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else { fp = (struct svr4_sigframe *)oldsp; } diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c index 6893712ba50..de6c79bda84 100644 --- a/sys/arch/sparc64/sparc64/machdep.c +++ b/sys/arch/sparc64/sparc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.130 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.131 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */ /*- @@ -460,13 +460,13 @@ sendsig(catcher, sig, mask, code, type, val) * Compute new user stack addresses, subtract off * one signal frame, and align. */ - onstack = p->p_sigstk.ss_flags & SS_ONSTACK; + onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !onstack && + if ((psp->ps_flags & SAS_ALTSTACK) && !onstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)((caddr_t)p->p_sigstk.ss_sp + - p->p_sigstk.ss_size); - p->p_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)((caddr_t)psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct sigframe *)oldsp; /* Allocate an aligned sigframe */ @@ -612,9 +612,9 @@ sys_sigreturn(p, v, retval) /* Restore signal stack. */ if (sc.sc_onstack & SS_ONSTACK) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; /* Restore signal mask. */ p->p_sigmask = scp->sc_mask & ~sigcantmask; diff --git a/sys/arch/vax/vax/machdep.c b/sys/arch/vax/vax/machdep.c index 507891e2695..ae4883faebc 100644 --- a/sys/arch/vax/vax/machdep.c +++ b/sys/arch/vax/vax/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.112 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.113 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.108 2000/09/13 15:00:23 thorpej Exp $ */ /* @@ -409,9 +409,9 @@ sys_sigreturn(p, v, retval) return (EINVAL); } if (ksc.sc_onstack & 01) - p->p_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; /* Restore signal mask. */ p->p_sigmask = ksc.sc_mask & ~sigcantmask; @@ -467,11 +467,11 @@ sendsig(catcher, sig, mask, code, type, val) int onstack; syscf = p->p_addr->u_pcb.framep; - onstack = p->p_sigstk.ss_flags & SS_ONSTACK; + onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; /* Allocate space for the signal handler context. */ if (onstack) - cursp = ((int)p->p_sigstk.ss_sp + p->p_sigstk.ss_size); + cursp = ((int)psp->ps_sigstk.ss_sp + psp->ps_sigstk.ss_size); else cursp = syscf->sp; @@ -489,7 +489,7 @@ sendsig(catcher, sig, mask, code, type, val) initsiginfo(&gsigf.sf_si, sig, code, type, val); } - gsigf.sf_sc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK; + gsigf.sf_sc.sc_onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; gsigf.sf_sc.sc_mask = mask; gsigf.sf_sc.sc_sp = syscf->sp; gsigf.sf_sc.sc_fp = syscf->fp; @@ -524,7 +524,7 @@ sendsig(catcher, sig, mask, code, type, val) syscf->ap = (unsigned)sigf + offsetof(struct sigframe, sf_pc); if (onstack) - p->p_sigstk.ss_flags |= SS_ONSTACK; + psp->ps_sigstk.ss_flags |= SS_ONSTACK; } int waittime = -1; diff --git a/sys/compat/common/kern_sig_43.c b/sys/compat/common/kern_sig_43.c index baaa833735e..83892a75350 100644 --- a/sys/compat/common/kern_sig_43.c +++ b/sys/compat/common/kern_sig_43.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig_43.c,v 1.10 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: kern_sig_43.c,v 1.11 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: kern_sig_43.c,v 1.7 1996/03/14 19:31:47 christos Exp $ */ /* @@ -112,26 +112,25 @@ compat_43_sys_sigstack(p, v, retval) syscallarg(struct sigstack *) oss; } */ *uap = v; struct sigstack ss; + struct sigacts *psp; int error = 0; - if (SCARG(uap, oss)) { - ss.ss_sp = p->p_sigstk.ss_sp; - ss.ss_onstack = p->p_sigstk.ss_flags & SS_ONSTACK; - if ((error = copyout(&ss, SCARG(uap, oss), sizeof(ss)))) - return (error); - } + psp = p->p_sigacts; + ss.ss_sp = psp->ps_sigstk.ss_sp; + ss.ss_onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; + if (SCARG(uap, oss) && (error = copyout((caddr_t)&ss, + (caddr_t)SCARG(uap, oss), sizeof (struct sigstack)))) + return (error); if (SCARG(uap, nss) == 0) return (0); - error = copyin(SCARG(uap, nss), &ss, sizeof(ss)); + error = copyin((caddr_t)SCARG(uap, nss), (caddr_t)&ss, + sizeof (ss)); if (error) return (error); - if (p->p_sigstk.ss_flags & SS_ONSTACK) - return (EPERM); - if (ss.ss_onstack) - return (EINVAL); - p->p_sigstk.ss_sp = ss.ss_sp; - p->p_sigstk.ss_size = 0; - p->p_sigstk.ss_flags = 0; + psp->ps_flags |= SAS_ALTSTACK; + psp->ps_sigstk.ss_sp = ss.ss_sp; + psp->ps_sigstk.ss_size = 0; + psp->ps_sigstk.ss_flags |= ss.ss_onstack & SS_ONSTACK; return (0); } @@ -172,7 +171,7 @@ compat_43_sys_sigvec(p, v, retval) sv->sv_flags |= SV_INTERRUPT; if ((ps->ps_sigreset & bit) != 0) sv->sv_flags |= SV_RESETHAND; - if (ps->ps_flags & SAS_NOCLDSTOP) + if (p->p_flag & P_NOCLDSTOP) sv->sv_flags |= SA_NOCLDSTOP; sv->sv_mask &= ~bit; error = copyout((caddr_t)sv, (caddr_t)SCARG(uap, osv), diff --git a/sys/compat/svr4/svr4_signal.c b/sys/compat/svr4/svr4_signal.c index 2b30b0144b2..b66f912912e 100644 --- a/sys/compat/svr4/svr4_signal.c +++ b/sys/compat/svr4/svr4_signal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_signal.c,v 1.13 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: svr4_signal.c,v 1.14 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: svr4_signal.c,v 1.24 1996/12/06 03:21:53 christos Exp $ */ /* @@ -650,7 +650,7 @@ svr4_sys_context(p, v, retval) case 0: DPRINTF(("getcontext(%p)\n", SCARG(uap, uc))); svr4_getcontext(p, &uc, p->p_sigmask, - p->p_sigstk.ss_flags & SS_ONSTACK); + p->p_sigacts->ps_sigstk.ss_flags & SS_ONSTACK); return copyout(&uc, SCARG(uap, uc), sizeof(uc)); case 1: diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index 92f3af0e761..980f49431ed 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.80 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.81 2011/04/18 21:44:56 guenther Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -1147,13 +1147,13 @@ ELFNAMEEND(coredump_notes)(struct proc *p, void *iocookie, size_t *sizep) cpi.cpi_version = ELFCORE_PROCINFO_VERSION; cpi.cpi_cpisize = sizeof(cpi); - cpi.cpi_signo = p->p_sisig; - cpi.cpi_sigcode = p->p_sicode; + cpi.cpi_signo = p->p_sigacts->ps_sig; + cpi.cpi_sigcode = p->p_sigacts->ps_code; cpi.cpi_sigpend = p->p_siglist; cpi.cpi_sigmask = p->p_sigmask; - cpi.cpi_sigignore = p->p_sigacts->ps_sigignore; - cpi.cpi_sigcatch = p->p_sigacts->ps_sigcatch; + cpi.cpi_sigignore = p->p_sigignore; + cpi.cpi_sigcatch = p->p_sigcatch; cpi.cpi_pid = pr->ps_pid; cpi.cpi_ppid = pr->ps_pptr->ps_pid; diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 5c5025ef1c3..43dc7f0cb67 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.176 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: init_main.c,v 1.177 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -283,7 +283,7 @@ main(void *framep) session0.s_count = 1; session0.s_leader = pr; - atomic_setbits_int(&p->p_flag, P_SYSTEM); + atomic_setbits_int(&p->p_flag, P_SYSTEM | P_NOCLDWAIT); p->p_stat = SONPROC; pr->ps_nice = NZERO; p->p_emul = &emul_native; @@ -615,9 +615,6 @@ start_init(void *arg) check_console(p); - /* process 0 ignores SIGCHLD, but we can't */ - p->p_sigacts->ps_flags = 0; - /* * Need just enough stack to hold the faked-up "execve()" arguments. */ diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 854743e5183..03b6ed37f50 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.99 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.100 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -176,6 +176,7 @@ exit1(struct proc *p, int rv, int flags) if (p->p_flag & P_PROFIL) stopprofclock(p); p->p_ru = pool_get(&rusage_pool, PR_WAITOK); + p->p_sigignore = ~0; p->p_siglist = 0; timeout_del(&p->p_realit_to); timeout_del(&p->p_stats->p_virt_to); @@ -304,12 +305,11 @@ exit1(struct proc *p, int rv, int flags) /* * Notify parent that we're gone. If we have P_NOZOMBIE - * or parent has the SAS_NOCLDWAIT flag set, notify process 1 + * or parent has the P_NOCLDWAIT flag set, notify process 1 * instead (and hope it will handle this situation). */ if ((p->p_flag & P_NOZOMBIE) || - (pr->ps_pptr->ps_mainproc->p_sigacts->ps_flags & - SAS_NOCLDWAIT)) { + (pr->ps_pptr->ps_mainproc->p_flag & P_NOCLDWAIT)) { struct process *ppr = pr->ps_pptr; proc_reparent(pr, initproc->p_p); /* diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 53e72da6b78..8f5887236a0 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.120 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.121 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -242,9 +242,9 @@ sys_sigaction(struct proc *p, void *v, register_t *retval) if ((ps->ps_siginfo & bit) != 0) sa->sa_flags |= SA_SIGINFO; if (signum == SIGCHLD) { - if ((ps->ps_flags & SAS_NOCLDSTOP) != 0) + if ((p->p_flag & P_NOCLDSTOP) != 0) sa->sa_flags |= SA_NOCLDSTOP; - if ((ps->ps_flags & SAS_NOCLDWAIT) != 0) + if ((p->p_flag & P_NOCLDWAIT) != 0) sa->sa_flags |= SA_NOCLDWAIT; } if ((sa->sa_mask & bit) == 0) @@ -281,22 +281,21 @@ setsigvec(struct proc *p, int signum, struct sigaction *sa) ps->ps_catchmask[signum] = sa->sa_mask &~ sigcantmask; if (signum == SIGCHLD) { if (sa->sa_flags & SA_NOCLDSTOP) - atomic_setbits_int(&ps->ps_flags, SAS_NOCLDSTOP); + atomic_setbits_int(&p->p_flag, P_NOCLDSTOP); else - atomic_clearbits_int(&ps->ps_flags, SAS_NOCLDSTOP); + atomic_clearbits_int(&p->p_flag, P_NOCLDSTOP); /* * If the SA_NOCLDWAIT flag is set or the handler * is SIG_IGN we reparent the dying child to PID 1 * (init) which will reap the zombie. Because we use - * init to do our dirty work we never set SAS_NOCLDWAIT + * init to do our dirty work we never set P_NOCLDWAIT * for PID 1. */ - if (initproc->p_sigacts != ps && - ((sa->sa_flags & SA_NOCLDWAIT) || + if (p->p_pid != 1 && ((sa->sa_flags & SA_NOCLDWAIT) || sa->sa_handler == SIG_IGN)) - atomic_setbits_int(&ps->ps_flags, SAS_NOCLDWAIT); + atomic_setbits_int(&p->p_flag, P_NOCLDWAIT); else - atomic_clearbits_int(&ps->ps_flags, SAS_NOCLDWAIT); + atomic_clearbits_int(&p->p_flag, P_NOCLDWAIT); } if ((sa->sa_flags & SA_RESETHAND) != 0) ps->ps_sigreset |= bit; @@ -315,23 +314,23 @@ setsigvec(struct proc *p, int signum, struct sigaction *sa) else ps->ps_sigonstack &= ~bit; /* - * Set bit in ps_sigignore for signals that are set to SIG_IGN, + * Set bit in p_sigignore for signals that are set to SIG_IGN, * and for signals set to SIG_DFL where the default is to ignore. - * However, don't put SIGCONT in ps_sigignore, + * However, don't put SIGCONT in p_sigignore, * as we have to restart the process. */ if (sa->sa_handler == SIG_IGN || (sigprop[signum] & SA_IGNORE && sa->sa_handler == SIG_DFL)) { atomic_clearbits_int(&p->p_siglist, bit); if (signum != SIGCONT) - ps->ps_sigignore |= bit; /* easier in psignal */ - ps->ps_sigcatch &= ~bit; + p->p_sigignore |= bit; /* easier in psignal */ + p->p_sigcatch &= ~bit; } else { - ps->ps_sigignore &= ~bit; + p->p_sigignore &= ~bit; if (sa->sa_handler == SIG_DFL) - ps->ps_sigcatch &= ~bit; + p->p_sigcatch &= ~bit; else - ps->ps_sigcatch |= bit; + p->p_sigcatch |= bit; } splx(s); } @@ -343,13 +342,11 @@ setsigvec(struct proc *p, int signum, struct sigaction *sa) void siginit(struct proc *p) { - struct sigacts *ps = p->p_sigacts; int i; for (i = 0; i < NSIG; i++) if (sigprop[i] & SA_IGNORE && i != SIGCONT) - ps->ps_sigignore |= sigmask(i); - ps->ps_flags = SAS_NOCLDWAIT | SAS_NOCLDSTOP; + p->p_sigignore |= sigmask(i); } /* @@ -369,13 +366,13 @@ execsigs(struct proc *p) * through p_sigmask (unless they were caught, * and are now ignored by default). */ - while (ps->ps_sigcatch) { - nc = ffs((long)ps->ps_sigcatch); + while (p->p_sigcatch) { + nc = ffs((long)p->p_sigcatch); mask = sigmask(nc); - ps->ps_sigcatch &= ~mask; + p->p_sigcatch &= ~mask; if (sigprop[nc] & SA_IGNORE) { if (nc != SIGCONT) - ps->ps_sigignore |= mask; + p->p_sigignore |= mask; atomic_clearbits_int(&p->p_siglist, mask); } ps->ps_sigact[nc] = SIG_DFL; @@ -384,10 +381,11 @@ execsigs(struct proc *p) * Reset stack state to the user stack. * Clear set of signals caught on the signal stack. */ - p->p_sigstk.ss_flags = SS_DISABLE; - p->p_sigstk.ss_size = 0; - p->p_sigstk.ss_sp = 0; - ps->ps_flags &= ~SAS_NOCLDWAIT; + ps->ps_sigstk.ss_flags = SS_DISABLE; + ps->ps_sigstk.ss_size = 0; + ps->ps_sigstk.ss_sp = 0; + ps->ps_flags = 0; + atomic_clearbits_int(&p->p_flag, P_NOCLDWAIT); if (ps->ps_sigact[SIGCHLD] == SIG_IGN) ps->ps_sigact[SIGCHLD] = SIG_DFL; } @@ -461,8 +459,8 @@ sys_sigsuspend(struct proc *p, void *v, register_t *retval) * save it here and mark the sigacts structure * to indicate this. */ - p->p_oldmask = p->p_sigmask; - atomic_setbits_int(&p->p_flag, P_SIGSUSPEND); + ps->ps_oldmask = p->p_sigmask; + ps->ps_flags |= SAS_OLDMASK; p->p_sigmask = SCARG(uap, mask) &~ sigcantmask; while (tsleep(ps, PPAUSE|PCATCH, "pause", 0) == 0) /* void */; @@ -478,6 +476,7 @@ sys_osigaltstack(struct proc *p, void *v, register_t *retval) syscallarg(const struct osigaltstack *) nss; syscallarg(struct osigaltstack *) oss; } */ *uap = v; + struct sigacts *psp; struct osigaltstack ss; const struct osigaltstack *nss; struct osigaltstack *oss; @@ -486,10 +485,13 @@ sys_osigaltstack(struct proc *p, void *v, register_t *retval) nss = SCARG(uap, nss); oss = SCARG(uap, oss); + psp = p->p_sigacts; + if ((psp->ps_flags & SAS_ALTSTACK) == 0) + psp->ps_sigstk.ss_flags |= SS_DISABLE; if (oss) { - ss.ss_sp = p->p_sigstk.ss_sp; - ss.ss_size = p->p_sigstk.ss_size; - ss.ss_flags = p->p_sigstk.ss_flags; + ss.ss_sp = psp->ps_sigstk.ss_sp; + ss.ss_size = psp->ps_sigstk.ss_size; + ss.ss_flags = psp->ps_sigstk.ss_flags; if ((error = copyout(&ss, oss, sizeof(ss)))) return (error); } @@ -498,19 +500,19 @@ sys_osigaltstack(struct proc *p, void *v, register_t *retval) error = copyin(nss, &ss, sizeof(ss)); if (error) return (error); - if (p->p_sigstk.ss_flags & SS_ONSTACK) - return (EPERM); - if (ss.ss_flags & ~SS_DISABLE) - return (EINVAL); if (ss.ss_flags & SS_DISABLE) { - p->p_sigstk.ss_flags = ss.ss_flags; + if (psp->ps_sigstk.ss_flags & SS_ONSTACK) + return (EINVAL); + psp->ps_flags &= ~SAS_ALTSTACK; + psp->ps_sigstk.ss_flags = ss.ss_flags; return (0); } if (ss.ss_size < MINSIGSTKSZ) return (ENOMEM); - p->p_sigstk.ss_sp = ss.ss_sp; - p->p_sigstk.ss_size = ss.ss_size; - p->p_sigstk.ss_flags = ss.ss_flags; + psp->ps_flags |= SAS_ALTSTACK; + psp->ps_sigstk.ss_sp = ss.ss_sp; + psp->ps_sigstk.ss_size = ss.ss_size; + psp->ps_sigstk.ss_flags = ss.ss_flags; return (0); } @@ -521,6 +523,7 @@ sys_sigaltstack(struct proc *p, void *v, register_t *retval) syscallarg(const struct sigaltstack *) nss; syscallarg(struct sigaltstack *) oss; } */ *uap = v; + struct sigacts *psp; struct sigaltstack ss; const struct sigaltstack *nss; struct sigaltstack *oss; @@ -529,24 +532,28 @@ sys_sigaltstack(struct proc *p, void *v, register_t *retval) nss = SCARG(uap, nss); oss = SCARG(uap, oss); - if (oss && (error = copyout(&p->p_sigstk, oss, sizeof(p->p_sigstk)))) + psp = p->p_sigacts; + if ((psp->ps_flags & SAS_ALTSTACK) == 0) + psp->ps_sigstk.ss_flags |= SS_DISABLE; + if (oss && (error = copyout(&psp->ps_sigstk, + oss, sizeof(struct sigaltstack)))) return (error); if (nss == NULL) return (0); error = copyin(nss, &ss, sizeof(ss)); if (error) return (error); - if (p->p_sigstk.ss_flags & SS_ONSTACK) - return (EPERM); - if (ss.ss_flags & ~SS_DISABLE) - return (EINVAL); if (ss.ss_flags & SS_DISABLE) { - p->p_sigstk.ss_flags = ss.ss_flags; + if (psp->ps_sigstk.ss_flags & SS_ONSTACK) + return (EINVAL); + psp->ps_flags &= ~SAS_ALTSTACK; + psp->ps_sigstk.ss_flags = ss.ss_flags; return (0); } if (ss.ss_size < MINSIGSTKSZ) return (ENOMEM); - p->p_sigstk = ss; + psp->ps_flags |= SAS_ALTSTACK; + psp->ps_sigstk = ss; return (0); } @@ -730,7 +737,7 @@ trapsignal(struct proc *p, int signum, u_long code, int type, int mask; mask = sigmask(signum); - if ((p->p_flag & P_TRACED) == 0 && (ps->ps_sigcatch & mask) != 0 && + if ((p->p_flag & P_TRACED) == 0 && (p->p_sigcatch & mask) != 0 && (p->p_sigmask & mask) == 0) { #ifdef KTRACE if (KTRPOINT(p, KTR_PSIG)) { @@ -746,16 +753,16 @@ trapsignal(struct proc *p, int signum, u_long code, int type, p->p_sigmask, code, type, sigval); p->p_sigmask |= ps->ps_catchmask[signum]; if ((ps->ps_sigreset & mask) != 0) { - ps->ps_sigcatch &= ~mask; + p->p_sigcatch &= ~mask; if (signum != SIGCONT && sigprop[signum] & SA_IGNORE) - ps->ps_sigignore |= mask; + p->p_sigignore |= mask; ps->ps_sigact[signum] = SIG_DFL; } } else { - p->p_sisig = signum; - p->p_sicode = code; /* XXX for core dump/debugger */ - p->p_sitype = type; - p->p_sigval = sigval; + ps->ps_sig = signum; + ps->ps_code = code; /* XXX for core dump/debugger */ + ps->ps_type = type; + ps->ps_sigval = sigval; ptsignal(p, signum, STHREAD); } } @@ -838,15 +845,15 @@ ptsignal(struct proc *p, int signum, enum signal_type type) /* * If the signal is being ignored, * then we forget about it immediately. - * (Note: we don't set SIGCONT in ps_sigignore, + * (Note: we don't set SIGCONT in p_sigignore, * and if it is set to SIG_IGN, * action will be SIG_DFL here.) */ - if (p->p_sigacts->ps_sigignore & mask) + if (p->p_sigignore & mask) return; if (p->p_sigmask & mask) action = SIG_HOLD; - else if (p->p_sigacts->ps_sigcatch & mask) + else if (p->p_sigcatch & mask) action = SIG_CATCH; else { action = SIG_DFL; @@ -1061,8 +1068,7 @@ issignal(struct proc *p) * We should see pending but ignored signals * only if P_TRACED was on when they were posted. */ - if (mask & p->p_sigacts->ps_sigignore && - (p->p_flag & P_TRACED) == 0) + if (mask & p->p_sigignore && (p->p_flag & P_TRACED) == 0) continue; if (p->p_flag & P_TRACED && @@ -1222,8 +1228,7 @@ proc_stop_sweep(void *v) continue; atomic_clearbits_int(&p->p_flag, P_STOPPED); - if ((p->p_p->ps_pptr->ps_mainproc->p_sigacts->ps_flags & - SAS_NOCLDSTOP) == 0) + if ((p->p_p->ps_pptr->ps_mainproc->p_flag & P_NOCLDSTOP) == 0) prsignal(p->p_p->ps_pptr, SIGCHLD); wakeup(p->p_p->ps_pptr); } @@ -1257,14 +1262,14 @@ postsig(int signum) sigval.sival_ptr = 0; type = SI_USER; - if (p->p_sisig != signum) { + if (ps->ps_sig != signum) { code = 0; type = SI_USER; sigval.sival_ptr = 0; } else { - code = p->p_sicode; - type = p->p_sitype; - sigval = p->p_sigval; + code = ps->ps_code; + type = ps->ps_type; + sigval = ps->ps_sigval; } #ifdef KTRACE @@ -1272,8 +1277,8 @@ postsig(int signum) siginfo_t si; initsiginfo(&si, signum, code, type, sigval); - ktrpsig(p, signum, action, p->p_flag & P_SIGSUSPEND ? - p->p_oldmask : p->p_sigmask, type, &si); + ktrpsig(p, signum, action, ps->ps_flags & SAS_OLDMASK ? + ps->ps_oldmask : p->p_sigmask, type, &si); } #endif if (action == SIG_DFL) { @@ -1305,25 +1310,25 @@ postsig(int signum) #else s = splhigh(); #endif - if (p->p_flag & P_SIGSUSPEND) { - atomic_clearbits_int(&p->p_flag, P_SIGSUSPEND); - returnmask = p->p_oldmask; + if (ps->ps_flags & SAS_OLDMASK) { + returnmask = ps->ps_oldmask; + ps->ps_flags &= ~SAS_OLDMASK; } else returnmask = p->p_sigmask; p->p_sigmask |= ps->ps_catchmask[signum]; if ((ps->ps_sigreset & mask) != 0) { - ps->ps_sigcatch &= ~mask; + p->p_sigcatch &= ~mask; if (signum != SIGCONT && sigprop[signum] & SA_IGNORE) - ps->ps_sigignore |= mask; + p->p_sigignore |= mask; ps->ps_sigact[signum] = SIG_DFL; } splx(s); p->p_stats->p_ru.ru_nsignals++; - if (p->p_sisig == signum) { - p->p_sisig = 0; - p->p_sicode = 0; - p->p_sitype = SI_USER; - p->p_sigval.sival_ptr = NULL; + if (ps->ps_sig == signum) { + ps->ps_sig = 0; + ps->ps_code = 0; + ps->ps_type = SI_USER; + ps->ps_sigval.sival_ptr = NULL; } (*p->p_emul->e_sendsig)(action, signum, returnmask, code, @@ -1349,7 +1354,7 @@ sigexit(struct proc *p, int signum) p->p_acflag |= AXSIG; if (sigprop[signum] & SA_CORE) { - p->p_sisig = signum; + p->p_sigacts->ps_sig = signum; if (coredump(p) == 0) signum |= WCOREFLAG; } @@ -1474,8 +1479,8 @@ coredump_trad(struct proc *p, void *cookie) core.c_midmag = 0; strlcpy(core.c_name, p->p_comm, sizeof(core.c_name)); core.c_nseg = 0; - core.c_signo = p->p_sisig; - core.c_ucode = p->p_sicode; + core.c_signo = p->p_sigacts->ps_sig; + core.c_ucode = p->p_sigacts->ps_code; core.c_cpusize = 0; core.c_tsize = (u_long)ptoa(vm->vm_tsize); core.c_dsize = (u_long)ptoa(vm->vm_dsize); diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index d48c77e4a34..768c5bb30fd 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.201 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.202 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -45,7 +45,6 @@ #include <sys/malloc.h> #include <sys/proc.h> #include <sys/resourcevar.h> -#include <sys/signalvar.h> #include <sys/file.h> #include <sys/filedesc.h> #include <sys/vnode.h> @@ -1474,7 +1473,7 @@ fill_kproc(struct proc *p, struct kinfo_proc *ki) struct timeval ut, st; FILL_KPROC(ki, strlcpy, p, pr, p->p_cred, p->p_ucred, pr->ps_pgrp, - p, pr, s, p->p_vmspace, pr->ps_limit, p->p_stats, p->p_sigacts); + p, pr, s, p->p_vmspace, pr->ps_limit, p->p_stats); /* stuff that's too painful to generalize into the macros */ if (pr->ps_pptr) diff --git a/sys/kern/tty.c b/sys/kern/tty.c index fbb6921eecc..1cf4a411f35 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.90 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: tty.c,v 1.91 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -750,7 +750,7 @@ ttioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p) #endif while (isbackground(pr, tp) && (pr->ps_flags & PS_PPWAIT) == 0 && - (p->p_sigacts->ps_sigignore & sigmask(SIGTTOU)) == 0 && + (p->p_sigignore & sigmask(SIGTTOU)) == 0 && (p->p_sigmask & sigmask(SIGTTOU)) == 0) { if (pr->ps_pgrp->pg_jobc == 0) return (EIO); @@ -1462,7 +1462,7 @@ loop: lflag = tp->t_lflag; * Hang process if it's in the background. */ if (isbackground(pr, tp)) { - if ((p->p_sigacts->ps_sigignore & sigmask(SIGTTIN)) || + if ((p->p_sigignore & sigmask(SIGTTIN)) || (p->p_sigmask & sigmask(SIGTTIN)) || pr->ps_flags & PS_PPWAIT || pr->ps_pgrp->pg_jobc == 0) { error = EIO; @@ -1719,7 +1719,7 @@ loop: pr = p->p_p; if (isbackground(pr, tp) && ISSET(tp->t_lflag, TOSTOP) && (pr->ps_flags & PS_PPWAIT) == 0 && - (p->p_sigacts->ps_sigignore & sigmask(SIGTTOU)) == 0 && + (p->p_sigignore & sigmask(SIGTTOU)) == 0 && (p->p_sigmask & sigmask(SIGTTOU)) == 0) { if (pr->ps_pgrp->pg_jobc == 0) { error = EIO; diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 2eef0737115..8539d2d54ce 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_pty.c,v 1.54 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: tty_pty.c,v 1.55 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */ /* @@ -291,7 +291,7 @@ ptsread(dev_t dev, struct uio *uio, int flag) again: if (pti->pt_flags & PF_REMOTE) { while (isbackground(pr, tp)) { - if ((p->p_sigacts->ps_sigignore & sigmask(SIGTTIN)) || + if ((p->p_sigignore & sigmask(SIGTTIN)) || (p->p_sigmask & sigmask(SIGTTIN)) || pr->ps_pgrp->pg_jobc == 0 || pr->ps_flags & PS_PPWAIT) diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c index c01ed252599..a4abf4848c3 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_socket.c,v 1.99 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: nfs_socket.c,v 1.100 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */ /* @@ -48,7 +48,6 @@ #include <sys/vnode.h> #include <sys/domain.h> #include <sys/protosw.h> -#include <sys/signalvar.h> #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/syslog.h> @@ -1234,7 +1233,7 @@ nfs_sigintr(struct nfsmount *nmp, struct nfsreq *rep, struct proc *p) if (!(nmp->nm_flag & NFSMNT_INT)) return (0); if (p && p->p_siglist && - (((p->p_siglist & ~p->p_sigmask) & ~p->p_sigacts->ps_sigignore) & + (((p->p_siglist & ~p->p_sigmask) & ~p->p_sigignore) & NFSINT_SIGMASK)) return (EINTR); return (0); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index b2f0ab61497..3c4b8d9c53f 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.137 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.138 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -183,6 +183,7 @@ struct process { * OR them together for export. */ #define PS_CONTROLT _P_CONTROLT +#define PS_NOCLDSTOP _P_NOCLDSTOP #define PS_PPWAIT _P_PPWAIT #define PS_PROFIL _P_PROFIL #define PS_SUGID _P_SUGID @@ -192,6 +193,7 @@ struct process { #define PS_EXEC _P_EXEC #define PS_ISPWAIT _P_ISPWAIT #define PS_SUGIDEXEC _P_SUGIDEXEC +#define PS_NOCLDWAIT _P_NOCLDWAIT #define PS_NOZOMBIE _P_NOZOMBIE #define PS_INEXEC _P_INEXEC #define PS_SYSTRACE _P_SYSTRACE @@ -270,7 +272,6 @@ struct proc { /* NULL. Malloc type M_EMULDATA */ sigset_t p_sigdivert; /* Signals to be diverted to thread. */ - struct sigaltstack p_sigstk; /* sp & on stack state variable */ /* End area that is zeroed on creation. */ #define p_endzero p_startcopy @@ -279,6 +280,8 @@ struct proc { #define p_startcopy p_sigmask sigset_t p_sigmask; /* Current signal mask. */ + sigset_t p_sigignore; /* Signals being ignored. */ + sigset_t p_sigcatch; /* Signals being caught by user. */ u_char p_priority; /* Process priority. */ u_char p_usrpri; /* User-priority based on p_cpu and ps_nice. */ @@ -290,12 +293,6 @@ struct proc { /* End area that is copied on creation. */ #define p_endcopy p_addr - sigset_t p_oldmask; /* Saved mask from before sigpause */ - union sigval p_sigval; /* For core dump/debugger XXX */ - long p_sicode; /* For core dump/debugger XXX */ - int p_sisig; /* For core dump/debugger XXX */ - int p_sitype; /* For core dump/debugger XXX */ - struct user *p_addr; /* Kernel virtual addr of u-area */ struct mdproc p_md; /* Any machine-dependent fields. */ @@ -321,7 +318,7 @@ struct proc { */ #define _P_CONTROLT 0x000002 /* Has a controlling terminal. */ #define P_INMEM 0x000004 /* Loaded into memory. UNUSED */ -#define P_SIGSUSPEND 0x000008 /* Need to restore before-suspend mask*/ +#define P_NOCLDSTOP 0x000008 /* No SIGCHLD when children stop. */ #define _P_PPWAIT 0x000010 /* Parent waits for exec/exit. */ #define P_PROFIL 0x000020 /* Has started profiling. */ #define P_SELECT 0x000040 /* Selecting; wakeup/waiting danger. */ @@ -343,6 +340,7 @@ struct proc { #define P_SSTEP 0x020000 /* proc needs single-step fixup ??? */ #define _P_SUGIDEXEC 0x040000 /* last execve() was set[ug]id */ +#define P_NOCLDWAIT 0x080000 /* Let pid 1 wait for my children */ #define P_NOZOMBIE 0x100000 /* Pid 1 waits for me instead of dad */ #define P_INEXEC 0x200000 /* Process is doing an exec right now */ #define P_SYSTRACE 0x400000 /* Process system call tracing active*/ @@ -363,9 +361,9 @@ struct proc { #endif #define P_BITS \ - ("\20\02CONTROLT\03INMEM\04SIGPAUSE\05PPWAIT\06PROFIL\07SELECT" \ + ("\20\02CONTROLT\03INMEM\04NOCLDSTOP\05PPWAIT\06PROFIL\07SELECT" \ "\010SINTR\011SUGID\012SYSTEM\013TIMEOUT\014TRACED\015WAITED\016WEXIT" \ - "\017EXEC\020PWEUPC\021ISPWAIT\022SSTEP\023SUGIDEXEC" \ + "\017EXEC\020PWEUPC\021ISPWAIT\022SSTEP\023SUGIDEXEC\024NOCLDWAIT" \ "\025NOZOMBIE\026INEXEC\027SYSTRACE\030CONTINUED\032BIGLOCK" \ "\033THREAD\034IGNEXITRV\035SOFTDEP\036STOPPED\037CPUPEG") diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index b1952750eab..8688168a5d3 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: signalvar.h,v 1.20 2011/04/15 04:52:40 guenther Exp $ */ +/* $OpenBSD: signalvar.h,v 1.21 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: signalvar.h,v 1.17 1996/04/22 01:23:31 christos Exp $ */ /* @@ -51,15 +51,20 @@ struct sigacts { sigset_t ps_sigintr; /* signals that interrupt syscalls */ sigset_t ps_sigreset; /* signals that reset when caught */ sigset_t ps_siginfo; /* signals that provide siginfo */ - sigset_t ps_sigignore; /* signals being ignored */ - sigset_t ps_sigcatch; /* signals being caught by user */ + sigset_t ps_oldmask; /* saved mask from before sigpause */ int ps_flags; /* signal flags, below */ + struct sigaltstack ps_sigstk; /* sp & on stack state variable */ + int ps_sig; /* for core dump/debugger XXX */ + long ps_code; /* for core dump/debugger XXX */ + int ps_type; /* for core dump/debugger XXX */ + union sigval ps_sigval; /* for core dump/debugger XXX */ + sigset_t ps_usertramp; /* SunOS compat; libc sigtramp XXX */ int ps_refcnt; /* reference count */ }; /* signal flags */ -#define SAS_NOCLDSTOP 0x01 /* No SIGCHLD when children stop. */ -#define SAS_NOCLDWAIT 0x02 /* No zombies if child dies */ +#define SAS_OLDMASK 0x01 /* need to restore mask before pause */ +#define SAS_ALTSTACK 0x02 /* have alternate signal stack */ /* additional signal action values, used only temporarily/internally */ #define SIG_CATCH (void (*)(int))2 diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 774691daab8..ca0619f1da1 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.112 2011/04/15 17:58:25 guenther Exp $ */ +/* $OpenBSD: sysctl.h,v 1.113 2011/04/18 21:44:56 guenther Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -464,7 +464,6 @@ struct kinfo_proc { * vm - source struct vmspace * lim - source struct plimits * ps - source struct pstats - * sa - source struct sigacts * There are some members that are not handled by these macros * because they're too painful to generalize: p_ppid, p_sid, p_tdev, * p_tpgid, p_tsess, p_vm_rssize, p_u[us]time_{sec,usec}, p_cpuid @@ -472,7 +471,7 @@ struct kinfo_proc { #define PTRTOINT64(_x) ((u_int64_t)(u_long)(_x)) -#define FILL_KPROC(kp, copy_str, p, pr, pc, uc, pg, paddr, praddr, sess, vm, lim, ps, sa) \ +#define FILL_KPROC(kp, copy_str, p, pr, pc, uc, pg, paddr, praddr, sess, vm, lim, ps) \ do { \ memset((kp), 0, sizeof(*(kp))); \ \ @@ -519,8 +518,8 @@ do { \ \ (kp)->p_siglist = (p)->p_siglist; \ (kp)->p_sigmask = (p)->p_sigmask; \ - (kp)->p_sigignore = (sa) ? (sa)->ps_sigignore : 0; \ - (kp)->p_sigcatch = (sa) ? (sa)->ps_sigcatch : 0; \ + (kp)->p_sigignore = (p)->p_sigignore; \ + (kp)->p_sigcatch = (p)->p_sigcatch; \ \ (kp)->p_stat = (p)->p_stat; \ (kp)->p_nice = (pr)->ps_nice; \ |