diff options
39 files changed, 329 insertions, 324 deletions
diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index 3603a1a8f27..53abcf59a99 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ps.1,v 1.72 2011/04/03 18:14:01 guenther Exp $ +.\" $OpenBSD: ps.1,v 1.73 2011/04/15 04:52:40 guenther Exp $ .\" $NetBSD: ps.1,v 1.16 1996/03/21 01:36:28 jtc Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 @@ -30,7 +30,7 @@ .\" .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" -.Dd $Mdocdate: April 3 2011 $ +.Dd $Mdocdate: April 15 2011 $ .Dt PS 1 .Os .Sh NAME @@ -219,7 +219,7 @@ and the thread as in the include file .Aq Pa sys/proc.h : .Bd -literal PS_CONTROLT 0x2 process has a controlling terminal -P_NOCLDSTOP 0x8 no SIGCHLD when children stop +P_SIGSUSPEND 0x8 need to restore before-suspend mask PS_PPWAIT 0x10 parent is waiting for child to exec/exit P_PROFIL 0x20 process has started profiling @@ -234,14 +234,13 @@ P_TRACED 0x800 process is being traced P_WAITED 0x1000 debugging process has waited for child P_WEXIT 0x2000 working on exiting -P_EXEC 0x4000 process called exec(3) +PS_EXEC 0x4000 process called exec(3) P_OWEUPC 0x8000 owe process an addupc() call at next ast .\" the routine addupc is not documented in the man pages PS_ISPWAIT 0x10000 is parent of PPWAIT child P_SSTEP 0x20000 process needs single-step fixup PS_SUGIDEXEC 0x40000 last exec(3) was set[ug]id -P_NOCLDWAIT 0x80000 let pid 1 wait for my children P_NOZOMBIE 0x100000 pid 1 waits for me instead of dad P_INEXEC 0x200000 process is doing an exec right now P_SYSTRACE 0x400000 process system call tracing is active diff --git a/lib/libkvm/kvm_proc2.c b/lib/libkvm/kvm_proc2.c index 1ba2e38945c..5610641292e 100644 --- a/lib/libkvm/kvm_proc2.c +++ b/lib/libkvm/kvm_proc2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_proc2.c,v 1.4 2011/03/12 04:54:28 guenther Exp $ */ +/* $OpenBSD: kvm_proc2.c,v 1.5 2011/04/15 04:52:40 guenther Exp $ */ /* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -77,6 +77,7 @@ #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/tty.h> +#include <sys/signalvar.h> #include <stddef.h> #include <stdlib.h> #include <string.h> @@ -113,6 +114,7 @@ kvm_proclist(kvm_t *kd, int op, int arg, struct proc *p, struct process process, process2; struct pgrp pgrp; struct tty tty; + struct sigacts sa; struct vmspace vm, *vmp; struct plimit limits, *limp; struct pstats pstats, *ps; @@ -188,6 +190,11 @@ kvm_proclist(kvm_t *kd, int op, int arg, struct proc *p, } else leader_pid = 0; + if (KREAD(kd, (u_long)proc.p_sigacts, &sa)) { + _kvm_err(kd, kd->program, "can't read sigacts at %x", + proc.p_sigacts); + return (-1); + } switch (op) { case KERN_PROC_PID: @@ -266,7 +273,7 @@ kvm_proclist(kvm_t *kd, int op, int arg, struct proc *p, #define do_copy_str(_d, _s, _l) kvm_read(kd, (u_long)(_s), (_d), (_l)-1) FILL_KPROC(&kp, do_copy_str, &proc, &process, &pcred, &ucred, - &pgrp, p, proc.p_p, &sess, vmp, limp, ps); + &pgrp, p, proc.p_p, &sess, vmp, limp, ps, &sa); #undef do_copy_str /* stuff that's too painful to generalize into the macros */ diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c index 9a64256b849..f7c6c247463 100644 --- a/sys/arch/alpha/alpha/machdep.c +++ b/sys/arch/alpha/alpha/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.128 2010/11/28 21:00:03 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.129 2011/04/15 04:52:39 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + oonstack = p->p_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 ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - scp = (struct sigcontext *)(psp->ps_sigstk.ss_sp + - psp->ps_sigstk.ss_size - rndfsize); - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + scp = (struct sigcontext *)(p->p_sigstk.ss_sp + + p->p_sigstk.ss_size - rndfsize); + p->p_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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 078527a1ebd..68e021f11dd 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.137 2011/04/13 02:49:12 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.138 2011/04/15 04:52:39 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + ksc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK; ksc.sc_mask = mask; ksc.sc_fpstate = NULL; /* Allocate space for the signal handler context. */ - if ((psp->ps_flags & SAS_ALTSTACK) && !ksc.sc_onstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !ksc.sc_onstack && (psp->ps_sigonstack & sigmask(sig))) { - sp = (register_t)psp->ps_sigstk.ss_sp + psp->ps_sigstk.ss_size; - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + sp = (register_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size; + p->p_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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 fd710f677c6..28106a0857d 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.2 2004/02/16 15:40:00 miod Exp $ */ +/* $OpenBSD: sig_machdep.c,v 1.3 2011/04/15 04:52:39 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + int oonstack = p->p_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 ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { onstack = 1; - fp = (struct sigframe *)((caddr_t)psp->ps_sigstk.ss_sp + - psp->ps_sigstk.ss_size); + fp = (struct sigframe *)((caddr_t)p->p_sigstk.ss_sp + + p->p_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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + frame.sf_sc.sc_onstack = p->p_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) - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; } #if 0 @@ -270,9 +270,9 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) /* Restore signal stack. */ if (context.sc_onstack & SS_ONSTACK) - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - psp->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 203b2df2bff..17e47f69ad9 100644 --- a/sys/arch/hp300/hp300/trap.c +++ b/sys/arch/hp300/hp300/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.56 2010/07/02 19:57:14 tedu Exp $ */ +/* $OpenBSD: trap.c,v 1.57 2011/04/15 04:52:39 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_sigignore &= ~i; - p->p_sigcatch &= ~i; + p->p_sigacts->ps_sigignore &= ~i; + p->p_sigacts->ps_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 47eb01af4fc..f2876895b98 100644 --- a/sys/arch/hppa/hppa/machdep.c +++ b/sys/arch/hppa/hppa/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.199 2011/01/14 13:32:43 jsing Exp $ */ +/* $OpenBSD: machdep.c,v 1.200 2011/04/15 04:52:39 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + ksc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK; /* * Allocate space for the signal handler context. */ - if ((psp->ps_flags & SAS_ALTSTACK) && !ksc.sc_onstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !ksc.sc_onstack && (psp->ps_sigonstack & sigmask(sig))) { - scp = (register_t)psp->ps_sigstk.ss_sp; - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + scp = (register_t)p->p_sigstk.ss_sp; + p->p_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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 bea912da981..86928fd834c 100644 --- a/sys/arch/hppa64/hppa64/machdep.c +++ b/sys/arch/hppa64/hppa64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.33 2011/04/06 14:45:23 jsing Exp $ */ +/* $OpenBSD: machdep.c,v 1.34 2011/04/15 04:52:39 guenther Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -859,15 +859,15 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type, mtctl(0, CR_CCR); } - ksc.sc_onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; + ksc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK; /* * Allocate space for the signal handler context. */ - if ((psp->ps_flags & SAS_ALTSTACK) && !ksc.sc_onstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !ksc.sc_onstack && (psp->ps_sigonstack & sigmask(sig))) { - scp = (register_t)psp->ps_sigstk.ss_sp; - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + scp = (register_t)p->p_sigstk.ss_sp; + p->p_sigstk.ss_flags |= SS_ONSTACK; } else scp = (tf->tf_sp + 63) & ~63; @@ -966,9 +966,9 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) return (EINVAL); if (ksc.sc_onstack) - p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 23a4ab92f7c..63694f4fea5 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.37 2011/04/05 13:54:42 pirofti Exp $ */ +/* $OpenBSD: linux_machdep.c,v 1.38 2011/04/15 04:52:39 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; /* * Allocate space for the signal handler context. */ - if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - 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; + 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; } 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_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 8a82fac962b..679b6dffb53 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.489 2011/03/20 21:44:08 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.490 2011/04/15 04:52:39 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + int oonstack = p->p_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 ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - sp = (long)psp->ps_sigstk.ss_sp + psp->ps_sigstk.ss_size; - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + sp = (long)p->p_sigstk.ss_sp + p->p_sigstk.ss_size; + p->p_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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 8d33252061d..388e5087123 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.26 2008/03/18 14:29:25 kettenis Exp $ */ +/* $OpenBSD: svr4_machdep.c,v 1.27 2011/04/15 04:52:39 guenther Exp $ */ /* $NetBSD: svr4_machdep.c,v 1.24 1996/05/03 19:42:26 christos Exp $ */ /* @@ -66,7 +66,7 @@ svr4_getcontext(struct proc *p, struct svr4_ucontext *uc, int mask, struct sigacts *psp = p->p_sigacts; svr4_greg_t *r = uc->uc_mcontext.greg; struct svr4_sigaltstack *s = &uc->uc_stack; - struct sigaltstack *sf = &psp->ps_sigstk; + struct sigaltstack *sf = &p->p_sigstk; bzero(uc, sizeof(struct svr4_ucontext)); @@ -138,7 +138,7 @@ svr4_setcontext(struct proc *p, struct svr4_ucontext *uc) struct trapframe *tf; svr4_greg_t *r = uc->uc_mcontext.greg; struct svr4_sigaltstack *s = &uc->uc_stack; - struct sigaltstack *sf = &psp->ps_sigstk; + struct sigaltstack *sf = &p->p_sigstk; int mask; /* @@ -316,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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; /* * Allocate space for the signal handler context. */ - if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - 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; + 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; } 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 e79eb1d60b6..8c2b1aca73e 100644 --- a/sys/arch/i386/i386/vm86.c +++ b/sys/arch/i386/i386/vm86.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm86.c,v 1.18 2008/06/26 05:42:10 ray Exp $ */ +/* $OpenBSD: vm86.c,v 1.19 2011/04/15 04:52:39 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_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 6138801bfd7..eedfc32ddf7 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.22 2010/06/27 22:04:01 miod Exp $ */ +/* $OpenBSD: sig_machdep.c,v 1.23 2011/04/15 04:52:39 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + oonstack = p->p_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 ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + - psp->ps_sigstk.ss_size - fsize); - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(p->p_sigstk.ss_sp + + p->p_sigstk.ss_size - fsize); + p->p_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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 8557ec29145..7818639a416 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.10 2010/06/26 23:24:43 guenther Exp $ */ +/* $OpenBSD: sig_machdep.c,v 1.11 2011/04/15 04:52:39 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + oonstack = p->p_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 ((psp->ps_flags & SAS_ALTSTACK) && - (psp->ps_sigstk.ss_flags & SS_ONSTACK) == 0 && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && + (p->p_sigstk.ss_flags & SS_ONSTACK) == 0 && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + - psp->ps_sigstk.ss_size - fsize); - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(p->p_sigstk.ss_sp + + p->p_sigstk.ss_size - fsize); + p->p_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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 b0ffcc19754..42c089aba69 100644 --- a/sys/arch/mac68k/mac68k/trap.c +++ b/sys/arch/mac68k/mac68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.57 2010/07/02 19:57:14 tedu Exp $ */ +/* $OpenBSD: trap.c,v 1.58 2011/04/15 04:52:39 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_sigignore &= ~i; - p->p_sigcatch &= ~i; + p->p_sigacts->ps_sigignore &= ~i; + p->p_sigacts->ps_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 dc738063938..9dfd408df65 100644 --- a/sys/arch/macppc/macppc/machdep.c +++ b/sys/arch/macppc/macppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.123 2011/01/08 18:10:23 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.124 2011/04/15 04:52:39 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + oldonstack = p->p_sigstk.ss_flags & SS_ONSTACK; /* * Allocate stack space for signal handler. */ - if ((psp->ps_flags & SAS_ALTSTACK) + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oldonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(psp->ps_sigstk.ss_sp - + psp->ps_sigstk.ss_size); - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(p->p_sigstk.ss_sp + + p->p_sigstk.ss_size); + p->p_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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 21b925b71e2..117b484677b 100644 --- a/sys/arch/mips64/mips64/sendsig.c +++ b/sys/arch/mips64/mips64/sendsig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sendsig.c,v 1.14 2011/04/07 15:30:15 miod Exp $ */ +/* $OpenBSD: sendsig.c,v 1.15 2011/04/15 04:52:39 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 = psp->ps_sigstk.ss_flags & SA_ONSTACK; + oonstack = p->p_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 ((psp->ps_flags & SAS_ALTSTACK) && - (psp->ps_sigstk.ss_flags & SA_ONSTACK) == 0 && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && + (p->p_sigstk.ss_flags & SA_ONSTACK) == 0 && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + - psp->ps_sigstk.ss_size - fsize); - psp->ps_sigstk.ss_flags |= SA_ONSTACK; + fp = (struct sigframe *)(p->p_sigstk.ss_sp + + p->p_sigstk.ss_size - fsize); + p->p_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_sigacts->ps_sigstk.ss_flags |= SA_ONSTACK; + p->p_sigstk.ss_flags |= SA_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SA_ONSTACK; + p->p_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 64288da48d8..9216637bab0 100644 --- a/sys/arch/mvme68k/mvme68k/trap.c +++ b/sys/arch/mvme68k/mvme68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.71 2010/09/20 06:33:47 matthew Exp $ */ +/* $OpenBSD: trap.c,v 1.72 2011/04/15 04:52:39 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_sigignore &= ~i; - p->p_sigcatch &= ~i; + p->p_sigacts->ps_sigignore &= ~i; + p->p_sigacts->ps_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 83841797a7c..754ec737d30 100644 --- a/sys/arch/mvmeppc/mvmeppc/machdep.c +++ b/sys/arch/mvmeppc/mvmeppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.64 2010/12/21 14:56:24 claudio Exp $ */ +/* $OpenBSD: machdep.c,v 1.65 2011/04/15 04:52:39 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + oldonstack = p->p_sigstk.ss_flags & SS_ONSTACK; /* * Allocate stack space for signal handler. */ - if ((psp->ps_flags & SAS_ALTSTACK) + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oldonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(psp->ps_sigstk.ss_sp - + psp->ps_sigstk.ss_size); - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(p->p_sigstk.ss_sp + + p->p_sigstk.ss_size); + p->p_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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 25246f954ce..86882ef293a 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.27 2009/11/17 17:06:44 kettenis Exp $ */ +/* $OpenBSD: sh_machdep.c,v 1.28 2011/04/15 04:52:40 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 *ps = p->p_sigacts; + struct sigacts *psp = p->p_sigacts; siginfo_t *sip; int 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; + 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; } 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 (ps->ps_siginfo & sigmask(sig)) { + if (psp->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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 626faed79ff..953792648e7 100644 --- a/sys/arch/socppc/socppc/machdep.c +++ b/sys/arch/socppc/socppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.27 2011/01/08 18:10:22 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.28 2011/04/15 04:52:40 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + oldonstack = p->p_sigstk.ss_flags & SS_ONSTACK; /* * Allocate stack space for signal handler. */ - if ((psp->ps_flags & SAS_ALTSTACK) + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oldonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(psp->ps_sigstk.ss_sp - + psp->ps_sigstk.ss_size); - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(p->p_sigstk.ss_sp + + p->p_sigstk.ss_size); + p->p_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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 07d7372962a..82b241e1b80 100644 --- a/sys/arch/solbourne/solbourne/machdep.c +++ b/sys/arch/solbourne/solbourne/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.16 2010/07/02 19:57:14 tedu Exp $ */ +/* $OpenBSD: machdep.c,v 1.17 2011/04/15 04:52:40 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; /* * Compute new user stack addresses, subtract off * one signal frame, and align. */ - if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + - psp->ps_sigstk.ss_size); - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(p->p_sigstk.ss_sp + + p->p_sigstk.ss_size); + p->p_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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 d0f7f23502d..2e1cda76f1d 100644 --- a/sys/arch/sparc/sparc/machdep.c +++ b/sys/arch/sparc/sparc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.132 2011/04/07 15:30:16 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.133 2011/04/15 04:52:40 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; /* * Compute new user stack addresses, subtract off * one signal frame, and align. */ - if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + - psp->ps_sigstk.ss_size); - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)(p->p_sigstk.ss_sp + + p->p_sigstk.ss_size); + p->p_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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 1228ea135a0..ac557916175 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.14 2010/06/26 23:24:44 guenther Exp $ */ +/* $OpenBSD: svr4_machdep.c,v 1.15 2011/04/15 04:52:40 guenther Exp $ */ /* $NetBSD: svr4_machdep.c,v 1.24 1997/07/29 10:04:45 fair Exp $ */ /* @@ -220,7 +220,7 @@ svr4_setcontext(p, uc) register struct trapframe *tf; svr4_greg_t *r = uc->uc_mcontext.greg; struct svr4_sigaltstack *s = &uc->uc_stack; - struct sigaltstack *sf = &psp->ps_sigstk; + struct sigaltstack *sf = &p->p_sigstk; int mask; #ifdef FPU_CONTEXT svr4_fregset_t *f = &uc->uc_mcontext.freg; @@ -462,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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; /* * Allocate space for the signal handler context. */ - if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct svr4_sigframe *)(psp->ps_sigstk.ss_sp + - psp->ps_sigstk.ss_size); - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct svr4_sigframe *)(p->p_sigstk.ss_sp + + p->p_sigstk.ss_size); + p->p_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 29aa600588f..6893712ba50 100644 --- a/sys/arch/sparc64/sparc64/machdep.c +++ b/sys/arch/sparc64/sparc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.129 2011/04/07 15:30:16 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.130 2011/04/15 04:52:40 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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + onstack = p->p_sigstk.ss_flags & SS_ONSTACK; - if ((psp->ps_flags & SAS_ALTSTACK) && !onstack && + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !onstack && (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)((caddr_t)psp->ps_sigstk.ss_sp + - psp->ps_sigstk.ss_size); - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + fp = (struct sigframe *)((caddr_t)p->p_sigstk.ss_sp + + p->p_sigstk.ss_size); + p->p_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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 ac4a9c2f61d..507891e2695 100644 --- a/sys/arch/vax/vax/machdep.c +++ b/sys/arch/vax/vax/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.111 2010/12/21 14:56:24 claudio Exp $ */ +/* $OpenBSD: machdep.c,v 1.112 2011/04/15 04:52:40 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_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_sigstk.ss_flags |= SS_ONSTACK; else - p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + onstack = p->p_sigstk.ss_flags & SS_ONSTACK; /* Allocate space for the signal handler context. */ if (onstack) - cursp = ((int)psp->ps_sigstk.ss_sp + psp->ps_sigstk.ss_size); + cursp = ((int)p->p_sigstk.ss_sp + p->p_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 = psp->ps_sigstk.ss_flags & SS_ONSTACK; + gsigf.sf_sc.sc_onstack = p->p_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) - psp->ps_sigstk.ss_flags |= SS_ONSTACK; + p->p_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 55bab50015c..baaa833735e 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.9 2010/06/28 23:00:30 guenther Exp $ */ +/* $OpenBSD: kern_sig_43.c,v 1.10 2011/04/15 04:52:40 guenther Exp $ */ /* $NetBSD: kern_sig_43.c,v 1.7 1996/03/14 19:31:47 christos Exp $ */ /* @@ -112,25 +112,26 @@ compat_43_sys_sigstack(p, v, retval) syscallarg(struct sigstack *) oss; } */ *uap = v; struct sigstack ss; - struct sigacts *psp; int error = 0; - 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, 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); + } if (SCARG(uap, nss) == 0) return (0); - error = copyin((caddr_t)SCARG(uap, nss), (caddr_t)&ss, - sizeof (ss)); + error = copyin(SCARG(uap, nss), &ss, sizeof(ss)); if (error) return (error); - 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; + 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; return (0); } @@ -171,7 +172,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 (p->p_flag & P_NOCLDSTOP) + if (ps->ps_flags & SAS_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 a2f26b16edd..2b30b0144b2 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.12 2009/12/09 16:29:56 jsg Exp $ */ +/* $OpenBSD: svr4_signal.c,v 1.13 2011/04/15 04:52:40 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_sigacts->ps_sigstk.ss_flags & SS_ONSTACK); + p->p_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 fe425ad2b36..92f3af0e761 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.79 2011/04/05 12:50:15 guenther Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.80 2011/04/15 04:52:40 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_sigacts->ps_sig; - cpi.cpi_sigcode = p->p_sigacts->ps_code; + cpi.cpi_signo = p->p_sisig; + cpi.cpi_sigcode = p->p_sicode; cpi.cpi_sigpend = p->p_siglist; cpi.cpi_sigmask = p->p_sigmask; - cpi.cpi_sigignore = p->p_sigignore; - cpi.cpi_sigcatch = p->p_sigcatch; + cpi.cpi_sigignore = p->p_sigacts->ps_sigignore; + cpi.cpi_sigcatch = p->p_sigacts->ps_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 84dc1943c12..5c5025ef1c3 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.175 2011/03/07 07:07:13 guenther Exp $ */ +/* $OpenBSD: init_main.c,v 1.176 2011/04/15 04:52:40 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 | P_NOCLDWAIT); + atomic_setbits_int(&p->p_flag, P_SYSTEM); p->p_stat = SONPROC; pr->ps_nice = NZERO; p->p_emul = &emul_native; @@ -615,6 +615,9 @@ 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 40c73d9a7ab..854743e5183 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.98 2011/04/03 14:56:28 guenther Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.99 2011/04/15 04:52:40 guenther Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -176,7 +176,6 @@ 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); @@ -305,11 +304,12 @@ exit1(struct proc *p, int rv, int flags) /* * Notify parent that we're gone. If we have P_NOZOMBIE - * or parent has the P_NOCLDWAIT flag set, notify process 1 + * or parent has the SAS_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_flag & P_NOCLDWAIT)) { + (pr->ps_pptr->ps_mainproc->p_sigacts->ps_flags & + SAS_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 6e1c1ead1e9..53e72da6b78 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.119 2011/04/03 14:56:28 guenther Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.120 2011/04/15 04:52:40 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 ((p->p_flag & P_NOCLDSTOP) != 0) + if ((ps->ps_flags & SAS_NOCLDSTOP) != 0) sa->sa_flags |= SA_NOCLDSTOP; - if ((p->p_flag & P_NOCLDWAIT) != 0) + if ((ps->ps_flags & SAS_NOCLDWAIT) != 0) sa->sa_flags |= SA_NOCLDWAIT; } if ((sa->sa_mask & bit) == 0) @@ -281,21 +281,22 @@ 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(&p->p_flag, P_NOCLDSTOP); + atomic_setbits_int(&ps->ps_flags, SAS_NOCLDSTOP); else - atomic_clearbits_int(&p->p_flag, P_NOCLDSTOP); + atomic_clearbits_int(&ps->ps_flags, SAS_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 P_NOCLDWAIT + * init to do our dirty work we never set SAS_NOCLDWAIT * for PID 1. */ - if (p->p_pid != 1 && ((sa->sa_flags & SA_NOCLDWAIT) || + if (initproc->p_sigacts != ps && + ((sa->sa_flags & SA_NOCLDWAIT) || sa->sa_handler == SIG_IGN)) - atomic_setbits_int(&p->p_flag, P_NOCLDWAIT); + atomic_setbits_int(&ps->ps_flags, SAS_NOCLDWAIT); else - atomic_clearbits_int(&p->p_flag, P_NOCLDWAIT); + atomic_clearbits_int(&ps->ps_flags, SAS_NOCLDWAIT); } if ((sa->sa_flags & SA_RESETHAND) != 0) ps->ps_sigreset |= bit; @@ -314,23 +315,23 @@ setsigvec(struct proc *p, int signum, struct sigaction *sa) else ps->ps_sigonstack &= ~bit; /* - * Set bit in p_sigignore for signals that are set to SIG_IGN, + * Set bit in ps_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 p_sigignore, + * However, don't put SIGCONT in ps_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) - p->p_sigignore |= bit; /* easier in psignal */ - p->p_sigcatch &= ~bit; + ps->ps_sigignore |= bit; /* easier in psignal */ + ps->ps_sigcatch &= ~bit; } else { - p->p_sigignore &= ~bit; + ps->ps_sigignore &= ~bit; if (sa->sa_handler == SIG_DFL) - p->p_sigcatch &= ~bit; + ps->ps_sigcatch &= ~bit; else - p->p_sigcatch |= bit; + ps->ps_sigcatch |= bit; } splx(s); } @@ -342,11 +343,13 @@ 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) - p->p_sigignore |= sigmask(i); + ps->ps_sigignore |= sigmask(i); + ps->ps_flags = SAS_NOCLDWAIT | SAS_NOCLDSTOP; } /* @@ -366,13 +369,13 @@ execsigs(struct proc *p) * through p_sigmask (unless they were caught, * and are now ignored by default). */ - while (p->p_sigcatch) { - nc = ffs((long)p->p_sigcatch); + while (ps->ps_sigcatch) { + nc = ffs((long)ps->ps_sigcatch); mask = sigmask(nc); - p->p_sigcatch &= ~mask; + ps->ps_sigcatch &= ~mask; if (sigprop[nc] & SA_IGNORE) { if (nc != SIGCONT) - p->p_sigignore |= mask; + ps->ps_sigignore |= mask; atomic_clearbits_int(&p->p_siglist, mask); } ps->ps_sigact[nc] = SIG_DFL; @@ -381,11 +384,10 @@ execsigs(struct proc *p) * Reset stack state to the user stack. * Clear set of signals caught on the signal stack. */ - 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); + p->p_sigstk.ss_flags = SS_DISABLE; + p->p_sigstk.ss_size = 0; + p->p_sigstk.ss_sp = 0; + ps->ps_flags &= ~SAS_NOCLDWAIT; if (ps->ps_sigact[SIGCHLD] == SIG_IGN) ps->ps_sigact[SIGCHLD] = SIG_DFL; } @@ -459,8 +461,8 @@ sys_sigsuspend(struct proc *p, void *v, register_t *retval) * save it here and mark the sigacts structure * to indicate this. */ - ps->ps_oldmask = p->p_sigmask; - ps->ps_flags |= SAS_OLDMASK; + p->p_oldmask = p->p_sigmask; + atomic_setbits_int(&p->p_flag, P_SIGSUSPEND); p->p_sigmask = SCARG(uap, mask) &~ sigcantmask; while (tsleep(ps, PPAUSE|PCATCH, "pause", 0) == 0) /* void */; @@ -476,7 +478,6 @@ 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; @@ -485,13 +486,10 @@ 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 = psp->ps_sigstk.ss_sp; - ss.ss_size = psp->ps_sigstk.ss_size; - ss.ss_flags = psp->ps_sigstk.ss_flags; + ss.ss_sp = p->p_sigstk.ss_sp; + ss.ss_size = p->p_sigstk.ss_size; + ss.ss_flags = p->p_sigstk.ss_flags; if ((error = copyout(&ss, oss, sizeof(ss)))) return (error); } @@ -500,19 +498,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) { - if (psp->ps_sigstk.ss_flags & SS_ONSTACK) - return (EINVAL); - psp->ps_flags &= ~SAS_ALTSTACK; - psp->ps_sigstk.ss_flags = ss.ss_flags; + p->p_sigstk.ss_flags = ss.ss_flags; return (0); } if (ss.ss_size < MINSIGSTKSZ) return (ENOMEM); - 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; + p->p_sigstk.ss_sp = ss.ss_sp; + p->p_sigstk.ss_size = ss.ss_size; + p->p_sigstk.ss_flags = ss.ss_flags; return (0); } @@ -523,7 +521,6 @@ 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; @@ -532,28 +529,24 @@ sys_sigaltstack(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 && (error = copyout(&psp->ps_sigstk, - oss, sizeof(struct sigaltstack)))) + if (oss && (error = copyout(&p->p_sigstk, oss, sizeof(p->p_sigstk)))) 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) { - if (psp->ps_sigstk.ss_flags & SS_ONSTACK) - return (EINVAL); - psp->ps_flags &= ~SAS_ALTSTACK; - psp->ps_sigstk.ss_flags = ss.ss_flags; + p->p_sigstk.ss_flags = ss.ss_flags; return (0); } if (ss.ss_size < MINSIGSTKSZ) return (ENOMEM); - psp->ps_flags |= SAS_ALTSTACK; - psp->ps_sigstk = ss; + p->p_sigstk = ss; return (0); } @@ -737,7 +730,7 @@ trapsignal(struct proc *p, int signum, u_long code, int type, int mask; mask = sigmask(signum); - if ((p->p_flag & P_TRACED) == 0 && (p->p_sigcatch & mask) != 0 && + if ((p->p_flag & P_TRACED) == 0 && (ps->ps_sigcatch & mask) != 0 && (p->p_sigmask & mask) == 0) { #ifdef KTRACE if (KTRPOINT(p, KTR_PSIG)) { @@ -753,16 +746,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) { - p->p_sigcatch &= ~mask; + ps->ps_sigcatch &= ~mask; if (signum != SIGCONT && sigprop[signum] & SA_IGNORE) - p->p_sigignore |= mask; + ps->ps_sigignore |= mask; ps->ps_sigact[signum] = SIG_DFL; } } else { - ps->ps_sig = signum; - ps->ps_code = code; /* XXX for core dump/debugger */ - ps->ps_type = type; - ps->ps_sigval = sigval; + p->p_sisig = signum; + p->p_sicode = code; /* XXX for core dump/debugger */ + p->p_sitype = type; + p->p_sigval = sigval; ptsignal(p, signum, STHREAD); } } @@ -845,15 +838,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 p_sigignore, + * (Note: we don't set SIGCONT in ps_sigignore, * and if it is set to SIG_IGN, * action will be SIG_DFL here.) */ - if (p->p_sigignore & mask) + if (p->p_sigacts->ps_sigignore & mask) return; if (p->p_sigmask & mask) action = SIG_HOLD; - else if (p->p_sigcatch & mask) + else if (p->p_sigacts->ps_sigcatch & mask) action = SIG_CATCH; else { action = SIG_DFL; @@ -1068,7 +1061,8 @@ 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_sigignore && (p->p_flag & P_TRACED) == 0) + if (mask & p->p_sigacts->ps_sigignore && + (p->p_flag & P_TRACED) == 0) continue; if (p->p_flag & P_TRACED && @@ -1228,7 +1222,8 @@ proc_stop_sweep(void *v) continue; atomic_clearbits_int(&p->p_flag, P_STOPPED); - if ((p->p_p->ps_pptr->ps_mainproc->p_flag & P_NOCLDSTOP) == 0) + if ((p->p_p->ps_pptr->ps_mainproc->p_sigacts->ps_flags & + SAS_NOCLDSTOP) == 0) prsignal(p->p_p->ps_pptr, SIGCHLD); wakeup(p->p_p->ps_pptr); } @@ -1262,14 +1257,14 @@ postsig(int signum) sigval.sival_ptr = 0; type = SI_USER; - if (ps->ps_sig != signum) { + if (p->p_sisig != signum) { code = 0; type = SI_USER; sigval.sival_ptr = 0; } else { - code = ps->ps_code; - type = ps->ps_type; - sigval = ps->ps_sigval; + code = p->p_sicode; + type = p->p_sitype; + sigval = p->p_sigval; } #ifdef KTRACE @@ -1277,8 +1272,8 @@ postsig(int signum) siginfo_t si; initsiginfo(&si, signum, code, type, sigval); - ktrpsig(p, signum, action, ps->ps_flags & SAS_OLDMASK ? - ps->ps_oldmask : p->p_sigmask, type, &si); + ktrpsig(p, signum, action, p->p_flag & P_SIGSUSPEND ? + p->p_oldmask : p->p_sigmask, type, &si); } #endif if (action == SIG_DFL) { @@ -1310,25 +1305,25 @@ postsig(int signum) #else s = splhigh(); #endif - if (ps->ps_flags & SAS_OLDMASK) { - returnmask = ps->ps_oldmask; - ps->ps_flags &= ~SAS_OLDMASK; + if (p->p_flag & P_SIGSUSPEND) { + atomic_clearbits_int(&p->p_flag, P_SIGSUSPEND); + returnmask = p->p_oldmask; } else returnmask = p->p_sigmask; p->p_sigmask |= ps->ps_catchmask[signum]; if ((ps->ps_sigreset & mask) != 0) { - p->p_sigcatch &= ~mask; + ps->ps_sigcatch &= ~mask; if (signum != SIGCONT && sigprop[signum] & SA_IGNORE) - p->p_sigignore |= mask; + ps->ps_sigignore |= mask; ps->ps_sigact[signum] = SIG_DFL; } splx(s); p->p_stats->p_ru.ru_nsignals++; - if (ps->ps_sig == signum) { - ps->ps_sig = 0; - ps->ps_code = 0; - ps->ps_type = SI_USER; - ps->ps_sigval.sival_ptr = NULL; + if (p->p_sisig == signum) { + p->p_sisig = 0; + p->p_sicode = 0; + p->p_sitype = SI_USER; + p->p_sigval.sival_ptr = NULL; } (*p->p_emul->e_sendsig)(action, signum, returnmask, code, @@ -1354,7 +1349,7 @@ sigexit(struct proc *p, int signum) p->p_acflag |= AXSIG; if (sigprop[signum] & SA_CORE) { - p->p_sigacts->ps_sig = signum; + p->p_sisig = signum; if (coredump(p) == 0) signum |= WCOREFLAG; } @@ -1479,8 +1474,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_sigacts->ps_sig; - core.c_ucode = p->p_sigacts->ps_code; + core.c_signo = p->p_sisig; + core.c_ucode = p->p_sicode; 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 2ac85792d08..d48c77e4a34 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.200 2011/04/04 11:13:55 deraadt Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.201 2011/04/15 04:52:40 guenther Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -45,6 +45,7 @@ #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> @@ -1473,7 +1474,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, pr, s, p->p_vmspace, pr->ps_limit, p->p_stats, p->p_sigacts); /* 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 5b3769ae34a..fbb6921eecc 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.89 2011/04/03 14:56:28 guenther Exp $ */ +/* $OpenBSD: tty.c,v 1.90 2011/04/15 04:52:40 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_sigignore & sigmask(SIGTTOU)) == 0 && + (p->p_sigacts->ps_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_sigignore & sigmask(SIGTTIN)) || + if ((p->p_sigacts->ps_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_sigignore & sigmask(SIGTTOU)) == 0 && + (p->p_sigacts->ps_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 dde88c46a50..2eef0737115 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_pty.c,v 1.53 2011/04/03 14:56:28 guenther Exp $ */ +/* $OpenBSD: tty_pty.c,v 1.54 2011/04/15 04:52:40 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_sigignore & sigmask(SIGTTIN)) || + if ((p->p_sigacts->ps_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 4b8b718f725..c01ed252599 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_socket.c,v 1.98 2010/07/05 16:32:07 deraadt Exp $ */ +/* $OpenBSD: nfs_socket.c,v 1.99 2011/04/15 04:52:40 guenther Exp $ */ /* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */ /* @@ -48,6 +48,7 @@ #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> @@ -1233,7 +1234,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_sigignore) & + (((p->p_siglist & ~p->p_sigmask) & ~p->p_sigacts->ps_sigignore) & NFSINT_SIGMASK)) return (EINTR); return (0); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 68055ef2313..b2f0ab61497 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.136 2011/04/04 13:00:13 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.137 2011/04/15 04:52:40 guenther Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -183,7 +183,6 @@ 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 @@ -193,7 +192,6 @@ 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 @@ -272,6 +270,7 @@ 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 @@ -280,8 +279,6 @@ 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. */ @@ -293,6 +290,12 @@ 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. */ @@ -318,7 +321,7 @@ struct proc { */ #define _P_CONTROLT 0x000002 /* Has a controlling terminal. */ #define P_INMEM 0x000004 /* Loaded into memory. UNUSED */ -#define P_NOCLDSTOP 0x000008 /* No SIGCHLD when children stop. */ +#define P_SIGSUSPEND 0x000008 /* Need to restore before-suspend mask*/ #define _P_PPWAIT 0x000010 /* Parent waits for exec/exit. */ #define P_PROFIL 0x000020 /* Has started profiling. */ #define P_SELECT 0x000040 /* Selecting; wakeup/waiting danger. */ @@ -340,7 +343,6 @@ 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*/ @@ -361,9 +363,9 @@ struct proc { #endif #define P_BITS \ - ("\20\02CONTROLT\03INMEM\04NOCLDSTOP\05PPWAIT\06PROFIL\07SELECT" \ + ("\20\02CONTROLT\03INMEM\04SIGPAUSE\05PPWAIT\06PROFIL\07SELECT" \ "\010SINTR\011SUGID\012SYSTEM\013TIMEOUT\014TRACED\015WAITED\016WEXIT" \ - "\017EXEC\020PWEUPC\021ISPWAIT\022SSTEP\023SUGIDEXEC\024NOCLDWAIT" \ + "\017EXEC\020PWEUPC\021ISPWAIT\022SSTEP\023SUGIDEXEC" \ "\025NOZOMBIE\026INEXEC\027SYSTRACE\030CONTINUED\032BIGLOCK" \ "\033THREAD\034IGNEXITRV\035SOFTDEP\036STOPPED\037CPUPEG") diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index 27b2293694d..b1952750eab 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: signalvar.h,v 1.19 2010/07/26 01:56:27 guenther Exp $ */ +/* $OpenBSD: signalvar.h,v 1.20 2011/04/15 04:52:40 guenther Exp $ */ /* $NetBSD: signalvar.h,v 1.17 1996/04/22 01:23:31 christos Exp $ */ /* @@ -51,20 +51,15 @@ 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_oldmask; /* saved mask from before sigpause */ + sigset_t ps_sigignore; /* signals being ignored */ + sigset_t ps_sigcatch; /* signals being caught by user */ 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_OLDMASK 0x01 /* need to restore mask before pause */ -#define SAS_ALTSTACK 0x02 /* have alternate signal stack */ +#define SAS_NOCLDSTOP 0x01 /* No SIGCHLD when children stop. */ +#define SAS_NOCLDWAIT 0x02 /* No zombies if child dies */ /* 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 5de3000f636..217aa42a5a8 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.110 2011/04/04 11:13:53 deraadt Exp $ */ +/* $OpenBSD: sysctl.h,v 1.111 2011/04/15 04:52:40 guenther Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -464,6 +464,7 @@ 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 @@ -471,7 +472,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) \ +#define FILL_KPROC(kp, copy_str, p, pr, pc, uc, pg, paddr, praddr, sess, vm, lim, ps, sa) \ do { \ memset((kp), 0, sizeof(*(kp))); \ \ @@ -518,8 +519,8 @@ do { \ \ (kp)->p_siglist = (p)->p_siglist; \ (kp)->p_sigmask = (p)->p_sigmask; \ - (kp)->p_sigignore = (p)->p_sigignore; \ - (kp)->p_sigcatch = (p)->p_sigcatch; \ + (kp)->p_sigignore = (sa)->ps_sigignore; \ + (kp)->p_sigcatch = (sa)->ps_sigcatch; \ \ (kp)->p_stat = (p)->p_stat; \ (kp)->p_nice = (pr)->ps_nice; \ |