Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Clear PSL_TRACEDCHILD on ptrace(PT_DETACH)



details:   https://anonhg.NetBSD.org/src/rev/9a3a5a43862c
branches:  trunk
changeset: 932471:9a3a5a43862c
user:      kamil <kamil%NetBSD.org@localhost>
date:      Fri May 08 10:35:51 2020 +0000

description:
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.

diffstat:

 sys/kern/sys_ptrace_common.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r ee46223c239a -r 9a3a5a43862c sys/kern/sys_ptrace_common.c
--- a/sys/kern/sys_ptrace_common.c      Fri May 08 06:24:28 2020 +0000
+++ b/sys/kern/sys_ptrace_common.c      Fri May 08 10:35:51 2020 +0000
@@ -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 @@
                        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) {



Home | Main Index | Thread Index | Old Index