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
This commit is contained in:
Mariusz Zaborski 2019-08-05 19:59:23 +00:00
parent 217c81f334
commit 41fadb3fca

View file

@ -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: