Module Name:    src
Committed By:   kamil
Date:           Fri May  8 10:35:51 UTC 2020

Modified Files:
        src/sys/kern: sys_ptrace_common.c

Log Message:
Clear PSL_TRACEDCHILD on ptrace(PT_DETACH)

This avoids potential race of detaching and attaching to a prestarted
process and receiving SIGTRAP instead of SIGSTOP.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/kern/sys_ptrace_common.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/sys_ptrace_common.c
diff -u src/sys/kern/sys_ptrace_common.c:1.78 src/sys/kern/sys_ptrace_common.c:1.79
--- src/sys/kern/sys_ptrace_common.c:1.78	Sat Feb 22 09:24:05 2020
+++ src/sys/kern/sys_ptrace_common.c	Fri May  8 10:35:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_ptrace_common.c,v 1.78 2020/02/22 09:24:05 maxv Exp $	*/
+/*	$NetBSD: sys_ptrace_common.c,v 1.79 2020/05/08 10:35:51 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.78 2020/02/22 09:24:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.79 2020/05/08 10:35:51 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -1392,7 +1392,8 @@ do_ptrace(struct ptrace_methods *ptm, st
 			break;
 #endif
 		if (req == PT_DETACH) {
-			CLR(t->p_slflag, PSL_TRACED|PSL_SYSCALL);
+			CLR(t->p_slflag,
+			    PSL_TRACED|PSL_TRACEDCHILD|PSL_SYSCALL);
 
 			/* give process back to original parent or init */
 			if (t->p_opptr != t->p_pptr) {

Reply via email to