From bccc78a590be19ba3e2857b412568d36fd234194 Mon Sep 17 00:00:00 2001 From: christos Date: Thu, 2 Feb 2012 02:44:06 +0000 Subject: [PATCH] Disable PTRACE_FORK for vforked() children, because the parent is waiting and will not receive the SIGTRAP in time. --- sys/kern/kern_fork.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index f3c3aa20014f..5815b90fd2ae 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_fork.c,v 1.186 2011/09/02 20:06:29 christos Exp $ */ +/* $NetBSD: kern_fork.c,v 1.187 2012/02/02 02:44:06 christos Exp $ */ /*- * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.186 2011/09/02 20:06:29 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.187 2012/02/02 02:44:06 christos Exp $"); #include "opt_ktrace.h" @@ -460,8 +460,12 @@ fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize, LIST_INSERT_HEAD(&parent->p_children, p2, p_sibling); p2->p_exitsig = exitsig; /* signal for parent on exit */ + /* + * We don't want to tracefork vfork()ed processes because they + * will not receive the SIGTRAP until it is too late. + */ tracefork = (p1->p_slflag & (PSL_TRACEFORK|PSL_TRACED)) == - (PSL_TRACEFORK|PSL_TRACED); + (PSL_TRACEFORK|PSL_TRACED) && (flags && FORK_PPWAIT) == 0; if (tracefork) { p2->p_slflag |= PSL_TRACED; p2->p_opptr = p2->p_pptr;