summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2020-03-01 18:50:52 +0000
committermpi <mpi@openbsd.org>2020-03-01 18:50:52 +0000
commit105c1f68dc539469e0f62a6b1044c3c1541c7ce9 (patch)
tree7e7df9bb547148bda61c4f248c2416e70833ebd3
parentWhen activating a video port, don't bail out if activating an endpoint (diff)
downloadwireguard-openbsd-105c1f68dc539469e0f62a6b1044c3c1541c7ce9.tar.xz
wireguard-openbsd-105c1f68dc539469e0f62a6b1044c3c1541c7ce9.zip
Do not reparent a traced child to ourself inside wait(2).
When a traced process _exit(2)s, its (tracing) parent tries to give it back to the old parent. In the case where the old parent is the same as the tracing parent, there's no need to do this dance, so simply remove it from the list of zombies and free its descriptors. Fix a double report via wait(2) exposed by recent changes in make and newly imported ptrace(2) regression from NetBSD & FreeBSD. Diagnosed with help from espie@ & guenther@. ok claudio@, visa@
-rw-r--r--sys/kern/kern_exit.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 147f2737544..826d7e0419f 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.184 2020/02/28 17:03:05 mpi Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.185 2020/03/01 18:50:52 mpi Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -584,7 +584,8 @@ proc_finish_wait(struct proc *waiter, struct proc *p)
* we need to give it back to the old parent.
*/
pr = p->p_p;
- if (pr->ps_oppid && (tr = prfind(pr->ps_oppid))) {
+ if (pr->ps_oppid != 0 && (pr->ps_oppid != pr->ps_pptr->ps_pid) &&
+ (tr = prfind(pr->ps_oppid))) {
atomic_clearbits_int(&pr->ps_flags, PS_TRACED);
pr->ps_oppid = 0;
proc_reparent(pr, tr);