diff options
author | 2011-04-03 14:56:27 +0000 | |
---|---|---|
committer | 2011-04-03 14:56:27 +0000 | |
commit | c0ce47d96f277436fbde5279039dad42b016a9b2 (patch) | |
tree | ba57ac46912617f1c7dd53acb3befb855db19709 | |
parent | No need to include uvm/uvm_extern.h and fix a typo. (diff) | |
download | wireguard-openbsd-c0ce47d96f277436fbde5279039dad42b016a9b2.tar.xz wireguard-openbsd-c0ce47d96f277436fbde5279039dad42b016a9b2.zip |
Move PPWAIT flag from struct proc to process, so that rthreads in
a vforked child behave correctly. Have the parent in a vfork()
wait on a (different) flag in *its* process instead of the child
to prevent a possible use-after-free. When ktracing the child
return from a fork, call it rfork if an rthread was created.
ok blambert@
-rw-r--r-- | sys/arch/alpha/alpha/trap.c | 6 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/syscall.c | 6 | ||||
-rw-r--r-- | sys/arch/arm/arm/syscall.c | 6 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/trap.c | 6 | ||||
-rw-r--r-- | sys/arch/hppa64/hppa64/trap.c | 6 | ||||
-rw-r--r-- | sys/arch/i386/i386/trap.c | 6 | ||||
-rw-r--r-- | sys/arch/m68k/m68k/m68k_machdep.c | 6 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/trap.c | 6 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/trap.c | 6 | ||||
-rw-r--r-- | sys/arch/powerpc/powerpc/trap.c | 6 | ||||
-rw-r--r-- | sys/arch/sh/sh/trap.c | 6 | ||||
-rw-r--r-- | sys/arch/solbourne/solbourne/trap.c | 6 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/trap.c | 6 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/trap.c | 6 | ||||
-rw-r--r-- | sys/arch/vax/vax/trap.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_exec.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_exit.c | 10 | ||||
-rw-r--r-- | sys/kern/kern_fork.c | 16 | ||||
-rw-r--r-- | sys/kern/kern_sig.c | 9 | ||||
-rw-r--r-- | sys/kern/tty.c | 8 | ||||
-rw-r--r-- | sys/kern/tty_pty.c | 4 | ||||
-rw-r--r-- | sys/sys/proc.h | 9 |
22 files changed, 97 insertions, 56 deletions
diff --git a/sys/arch/alpha/alpha/trap.c b/sys/arch/alpha/alpha/trap.c index 52a6e93dfeb..5896a1379e0 100644 --- a/sys/arch/alpha/alpha/trap.c +++ b/sys/arch/alpha/alpha/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.57 2010/10/27 20:20:38 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.58 2011/04/03 14:56:27 guenther Exp $ */ /* $NetBSD: trap.c,v 1.52 2000/05/24 16:48:33 thorpej Exp $ */ /*- @@ -680,7 +680,9 @@ child_return(arg) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); #endif } diff --git a/sys/arch/amd64/amd64/syscall.c b/sys/arch/amd64/amd64/syscall.c index 928dabb0d7d..cabe03827e4 100644 --- a/sys/arch/amd64/amd64/syscall.c +++ b/sys/arch/amd64/amd64/syscall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.c,v 1.15 2010/06/26 23:24:43 guenther Exp $ */ +/* $OpenBSD: syscall.c,v 1.16 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: syscall.c,v 1.1 2003/04/26 18:39:32 fvdl Exp $ */ /*- @@ -210,7 +210,9 @@ child_return(void *arg) if (KTRPOINT(p, KTR_SYSRET)) { KERNEL_PROC_LOCK(p); ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); KERNEL_PROC_UNLOCK(p); } #endif diff --git a/sys/arch/arm/arm/syscall.c b/sys/arch/arm/arm/syscall.c index 7292bb599da..f3a02906c92 100644 --- a/sys/arch/arm/arm/syscall.c +++ b/sys/arch/arm/arm/syscall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.c,v 1.11 2010/04/21 03:03:25 deraadt Exp $ */ +/* $OpenBSD: syscall.c,v 1.12 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: syscall.c,v 1.24 2003/11/14 19:03:17 scw Exp $ */ /*- @@ -221,7 +221,9 @@ child_return(arg) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); } #endif } diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c index f94533cb348..139aa54a8a4 100644 --- a/sys/arch/hppa/hppa/trap.c +++ b/sys/arch/hppa/hppa/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.113 2011/01/23 15:09:12 jsing Exp $ */ +/* $OpenBSD: trap.c,v 1.114 2011/04/03 14:56:28 guenther Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -660,7 +660,9 @@ child_return(void *arg) if (KTRPOINT(p, KTR_SYSRET)) { KERNEL_PROC_LOCK(p); ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); KERNEL_PROC_UNLOCK(p); } #endif diff --git a/sys/arch/hppa64/hppa64/trap.c b/sys/arch/hppa64/hppa64/trap.c index 0a75c61e16d..d006a91d8d5 100644 --- a/sys/arch/hppa64/hppa64/trap.c +++ b/sys/arch/hppa64/hppa64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.15 2011/03/30 13:54:23 jsing Exp $ */ +/* $OpenBSD: trap.c,v 1.16 2011/04/03 14:56:28 guenther Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -566,7 +566,9 @@ child_return(arg) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); #endif } diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index aa91da28efb..4e54384fd7a 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.94 2010/07/20 00:16:39 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.95 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */ /*- @@ -786,7 +786,9 @@ child_return(void *arg) if (KTRPOINT(p, KTR_SYSRET)) { KERNEL_PROC_LOCK(p); ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); KERNEL_PROC_UNLOCK(p); } #endif diff --git a/sys/arch/m68k/m68k/m68k_machdep.c b/sys/arch/m68k/m68k/m68k_machdep.c index 1bede2cdeb0..595d5c4545f 100644 --- a/sys/arch/m68k/m68k/m68k_machdep.c +++ b/sys/arch/m68k/m68k/m68k_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m68k_machdep.c,v 1.14 2010/07/02 19:57:14 tedu Exp $ */ +/* $OpenBSD: m68k_machdep.c,v 1.15 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: m68k_machdep.c,v 1.3 1997/06/12 09:57:04 veego Exp $ */ /*- @@ -89,6 +89,8 @@ child_return(arg) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); #endif } diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c index b62d0b92058..ddd1f0103cb 100644 --- a/sys/arch/m88k/m88k/trap.c +++ b/sys/arch/m88k/m88k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.73 2010/12/31 20:54:21 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.74 2011/04/03 14:56:28 guenther Exp $ */ /* * Copyright (c) 2004, Miodrag Vallat. * Copyright (c) 1998 Steve Murphree, Jr. @@ -1520,7 +1520,9 @@ child_return(arg) if (KTRPOINT(p, KTR_SYSRET)) { KERNEL_PROC_LOCK(p); ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); KERNEL_PROC_UNLOCK(p); } #endif diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c index bc4c0d7290f..6e30ca2aa30 100644 --- a/sys/arch/mips64/mips64/trap.c +++ b/sys/arch/mips64/mips64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.72 2010/11/24 21:16:28 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.73 2011/04/03 14:56:28 guenther Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -846,7 +846,9 @@ child_return(arg) if (KTRPOINT(p, KTR_SYSRET)) { KERNEL_PROC_LOCK(p); ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); KERNEL_PROC_UNLOCK(p); } #endif diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c index 0c3a5d03873..57c6e342709 100644 --- a/sys/arch/powerpc/powerpc/trap.c +++ b/sys/arch/powerpc/powerpc/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.83 2008/06/14 10:55:20 mk Exp $ */ +/* $OpenBSD: trap.c,v 1.84 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */ /* @@ -734,7 +734,9 @@ child_return(void *arg) if (KTRPOINT(p, KTR_SYSRET)) { KERNEL_PROC_LOCK(p); ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); KERNEL_PROC_UNLOCK(p); } #endif diff --git a/sys/arch/sh/sh/trap.c b/sys/arch/sh/sh/trap.c index 85895c337bf..74ec6a38315 100644 --- a/sys/arch/sh/sh/trap.c +++ b/sys/arch/sh/sh/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.16 2010/06/27 12:41:23 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.17 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: exception.c,v 1.32 2006/09/04 23:57:52 uwe Exp $ */ /* $NetBSD: syscall.c,v 1.6 2006/03/07 07:21:50 thorpej Exp $ */ @@ -693,7 +693,9 @@ child_return(void *arg) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); #endif } diff --git a/sys/arch/solbourne/solbourne/trap.c b/sys/arch/solbourne/solbourne/trap.c index 2c613279751..254b2aae4e6 100644 --- a/sys/arch/solbourne/solbourne/trap.c +++ b/sys/arch/solbourne/solbourne/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.11 2009/04/10 20:57:28 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.12 2011/04/03 14:56:28 guenther Exp $ */ /* OpenBSD: trap.c,v 1.42 2004/12/06 20:12:25 miod Exp */ /* @@ -962,6 +962,8 @@ child_return(arg) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); #endif } diff --git a/sys/arch/sparc/sparc/trap.c b/sys/arch/sparc/sparc/trap.c index cf558026188..05380967914 100644 --- a/sys/arch/sparc/sparc/trap.c +++ b/sys/arch/sparc/sparc/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.55 2010/11/27 19:41:48 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.56 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: trap.c,v 1.58 1997/09/12 08:55:01 pk Exp $ */ /* @@ -1145,6 +1145,8 @@ child_return(arg) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); #endif } diff --git a/sys/arch/sparc64/sparc64/trap.c b/sys/arch/sparc64/sparc64/trap.c index 05159280724..d5e4bc32f7c 100644 --- a/sys/arch/sparc64/sparc64/trap.c +++ b/sys/arch/sparc64/sparc64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.66 2010/11/27 19:41:48 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.67 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */ /* @@ -1457,7 +1457,9 @@ child_return(arg) if (KTRPOINT(p, KTR_SYSRET)) { KERNEL_PROC_LOCK(p); ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); KERNEL_PROC_UNLOCK(p); } #endif diff --git a/sys/arch/vax/vax/trap.c b/sys/arch/vax/vax/trap.c index e31a0897d6c..e6e599a1000 100644 --- a/sys/arch/vax/vax/trap.c +++ b/sys/arch/vax/vax/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.40 2010/11/27 18:04:23 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.41 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: trap.c,v 1.47 1999/08/21 19:26:20 matt Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -462,6 +462,8 @@ child_return(arg) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, - (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); + (p->p_flag & P_THREAD) ? SYS_rfork : + (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, + 0, 0); #endif } diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 74b5647c3c3..65fe753077b 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exec.c,v 1.115 2011/04/02 17:04:35 guenther Exp $ */ +/* $OpenBSD: kern_exec.c,v 1.116 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */ /*- @@ -468,8 +468,9 @@ sys_execve(struct proc *p, void *v, register_t *retval) p->p_textvp = pack.ep_vp; atomic_setbits_int(&p->p_flag, P_EXEC); - if (pr->ps_mainproc->p_flag & P_PPWAIT) { - atomic_clearbits_int(&pr->ps_mainproc->p_flag, P_PPWAIT); + if (pr->ps_flags & PS_PPWAIT) { + atomic_clearbits_int(&pr->ps_flags, PS_PPWAIT); + atomic_clearbits_int(&pr->ps_pptr->ps_flags, PS_ISPWAIT); wakeup(pr->ps_pptr); } diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 792f8391340..40c73d9a7ab 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.97 2010/08/02 19:54:07 guenther Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.98 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -162,11 +162,13 @@ exit1(struct proc *p, int rv, int flags) while (!TAILQ_EMPTY(&pr->ps_threads)) tsleep(&pr->ps_threads, PUSER, "thrdeath", 0); /* - * If parent is waiting for us to exit or exec, P_PPWAIT + * If parent is waiting for us to exit or exec, PS_PPWAIT * is set; we wake up the parent early to avoid deadlock. */ - if (p->p_flag & P_PPWAIT) { - atomic_clearbits_int(&p->p_flag, P_PPWAIT); + if (pr->ps_flags & PS_PPWAIT) { + atomic_clearbits_int(&pr->ps_flags, PS_PPWAIT); + atomic_clearbits_int(&pr->ps_pptr->ps_flags, + PS_ISPWAIT); wakeup(pr->ps_pptr); } } diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 8707f472ac1..1753df4bbf3 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.124 2011/04/02 17:04:35 guenther Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.125 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -319,8 +319,10 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, else p2->p_fd = fdcopy(p1); - if (flags & FORK_PPWAIT) - atomic_setbits_int(&p2->p_flag, P_PPWAIT); + if (flags & FORK_PPWAIT) { + atomic_setbits_int(&p2->p_p->ps_flags, PS_PPWAIT); + atomic_setbits_int(&p1->p_p->ps_flags, PS_ISPWAIT); + } if (flags & FORK_NOZOMBIE) atomic_setbits_int(&p2->p_flag, P_NOZOMBIE); @@ -462,11 +464,13 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, /* * Preserve synchronization semantics of vfork. If waiting for - * child to exec or exit, set P_PPWAIT on child, and sleep on our - * process (in case of exit). + * child to exec or exit, set PS_PPWAIT on child and PS_ISPWAIT + * on ourselves, and sleep on our process for the latter flag + * to go away. + * XXX Need to stop other rthreads in the parent */ if (flags & FORK_PPWAIT) - while (p2->p_flag & P_PPWAIT) + while (p1->p_p->ps_flags & PS_ISPWAIT) tsleep(p1->p_p, PWAIT, "ppwait", 0); /* diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 39bf31572e7..6e1c1ead1e9 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.118 2011/04/02 17:04:35 guenther Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.119 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -938,7 +938,7 @@ ptsignal(struct proc *p, int signum, enum signal_type type) * If a child holding parent blocked, * stopping could cause deadlock. */ - if (p->p_flag & P_PPWAIT) + if (p->p_p->ps_flags & PS_PPWAIT) goto out; atomic_clearbits_int(&p->p_siglist, mask); p->p_xstat = signum; @@ -1056,7 +1056,7 @@ issignal(struct proc *p) for (;;) { mask = p->p_siglist & ~p->p_sigmask; - if (p->p_flag & P_PPWAIT) + if (p->p_p->ps_flags & PS_PPWAIT) mask &= ~stopsigmask; if (mask == 0) /* no signal to send */ return (0); @@ -1071,7 +1071,8 @@ issignal(struct proc *p) if (mask & p->p_sigignore && (p->p_flag & P_TRACED) == 0) continue; - if (p->p_flag & P_TRACED && (p->p_flag & P_PPWAIT) == 0) { + if (p->p_flag & P_TRACED && + (p->p_p->ps_flags & PS_PPWAIT) == 0) { /* * If traced, always stop, and stay * stopped until released by the debugger. diff --git a/sys/kern/tty.c b/sys/kern/tty.c index c8120bf02c6..5b3769ae34a 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.88 2010/07/26 01:56:27 guenther Exp $ */ +/* $OpenBSD: tty.c,v 1.89 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -749,7 +749,7 @@ ttioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p) case TIOCSLTC: #endif while (isbackground(pr, tp) && - (p->p_flag & P_PPWAIT) == 0 && + (pr->ps_flags & PS_PPWAIT) == 0 && (p->p_sigignore & sigmask(SIGTTOU)) == 0 && (p->p_sigmask & sigmask(SIGTTOU)) == 0) { if (pr->ps_pgrp->pg_jobc == 0) @@ -1464,7 +1464,7 @@ loop: lflag = tp->t_lflag; if (isbackground(pr, tp)) { if ((p->p_sigignore & sigmask(SIGTTIN)) || (p->p_sigmask & sigmask(SIGTTIN)) || - p->p_flag & P_PPWAIT || pr->ps_pgrp->pg_jobc == 0) { + pr->ps_flags & PS_PPWAIT || pr->ps_pgrp->pg_jobc == 0) { error = EIO; goto out; } @@ -1718,7 +1718,7 @@ loop: p = curproc; pr = p->p_p; if (isbackground(pr, tp) && - ISSET(tp->t_lflag, TOSTOP) && (p->p_flag & P_PPWAIT) == 0 && + ISSET(tp->t_lflag, TOSTOP) && (pr->ps_flags & PS_PPWAIT) == 0 && (p->p_sigignore & sigmask(SIGTTOU)) == 0 && (p->p_sigmask & sigmask(SIGTTOU)) == 0) { if (pr->ps_pgrp->pg_jobc == 0) { diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 9ad6757f7b1..dde88c46a50 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_pty.c,v 1.52 2010/09/24 02:59:39 deraadt Exp $ */ +/* $OpenBSD: tty_pty.c,v 1.53 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */ /* @@ -294,7 +294,7 @@ again: if ((p->p_sigignore & sigmask(SIGTTIN)) || (p->p_sigmask & sigmask(SIGTTIN)) || pr->ps_pgrp->pg_jobc == 0 || - p->p_flag & P_PPWAIT) + pr->ps_flags & PS_PPWAIT) return (EIO); pgsignal(pr->ps_pgrp, SIGTTIN, 1); error = ttysleep(tp, &lbolt, diff --git a/sys/sys/proc.h b/sys/sys/proc.h index b27ed7c0915..0991218cea4 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.134 2011/04/02 17:04:35 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.135 2011/04/03 14:56:28 guenther Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -191,6 +191,7 @@ struct process { #define PS_TRACED _P_TRACED #define PS_WAITED _P_WAITED #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 @@ -318,7 +319,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_PPWAIT 0x000010 /* Parent waits for child exec/exit. */ +#define _P_PPWAIT 0x000010 /* Parent waits for exec/exit. */ #define P_PROFIL 0x000020 /* Has started profiling. */ #define P_SELECT 0x000040 /* Selecting; wakeup/waiting danger. */ #define P_SINTR 0x000080 /* Sleep is interruptible. */ @@ -333,6 +334,7 @@ struct proc { /* Should be moved to machine-dependent areas. */ #define P_OWEUPC 0x008000 /* Owe proc an addupc() at next ast. */ +#define _P_ISPWAIT 0x010000 /* Is parent of PPWAIT child. */ /* XXX Not sure what to do with these, yet. */ #define P_SSTEP 0x020000 /* proc needs single-step fixup ??? */ @@ -352,6 +354,7 @@ struct proc { #ifndef _KERNEL #define P_CONTROLT _P_CONTROLT +#define P_PPWAIT _P_PPWAIT #define P_SUGID _P_SUGID #define P_SUGIDEXEC _P_SUGIDEXEC #endif @@ -359,7 +362,7 @@ struct proc { #define P_BITS \ ("\20\02CONTROLT\03INMEM\04NOCLDSTOP\05PPWAIT\06PROFIL\07SELECT" \ "\010SINTR\011SUGID\012SYSTEM\013TIMEOUT\014TRACED\015WAITED\016WEXIT" \ - "\017EXEC\020PWEUPC\022SSTEP\023SUGIDEXEC\024NOCLDWAIT" \ + "\017EXEC\020PWEUPC\021ISPWAIT\022SSTEP\023SUGIDEXEC\024NOCLDWAIT" \ "\025NOZOMBIE\026INEXEC\027SYSTRACE\030CONTINUED\032BIGLOCK" \ "\033THREAD\034IGNEXITRV\035SOFTDEP\036STOPPED\037CPUPEG") |