From 41fadb3fca6feff88f3dfc0e141f7cbf9306080b Mon Sep 17 00:00:00 2001 From: Mariusz Zaborski Date: Mon, 5 Aug 2019 19:59:23 +0000 Subject: [PATCH] exit1: postpone clearing P_TRACED flag until the proctree lock is acquired In case of the process being debugged. The P_TRACED is cleared very early, which would make procdesc_close() not calling proc_clear_orphan(). That would result in the debugged process can not be able to collect status of the process with process descriptor. Reviewed by: markj, kib Tested by: pho MFC after: 1 month --- sys/kern/kern_exit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 458912a504d..1b1e52b06bd 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -355,7 +355,6 @@ exit1(struct thread *td, int rval, int signo) */ PROC_LOCK(p); stopprofclock(p); - p->p_flag &= ~(P_TRACED | P_PPWAIT | P_PPTRACE); p->p_ptevents = 0; /* @@ -458,6 +457,9 @@ exit1(struct thread *td, int rval, int signo) sx_xunlock(&allproc_lock); sx_xlock(&proctree_lock); + PROC_LOCK(p); + p->p_flag &= ~(P_TRACED | P_PPWAIT | P_PPTRACE); + PROC_UNLOCK(p); /* * Reparent all children processes: