svn commit: r304487 - in head/sys: kern sys
Mark Johnston
markj at FreeBSD.org
Fri Aug 19 17:57:15 UTC 2016
Author: markj
Date: Fri Aug 19 17:57:14 2016
New Revision: 304487
URL: https://svnweb.freebsd.org/changeset/base/304487
Log:
Don't set P2_PTRACE_FSTP in a process that invokes ptrace(PT_TRACE_ME).
Such processes are stopped synchronously by a direct call to
ptracestop(SIGTRAP) upon exec. P2_PTRACE_FSTP causes the exec()ing thread
to suspend itself while waiting for a SIGSTOP that never arrives.
Reviewed by: kib
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D7576
Modified:
head/sys/kern/kern_fork.c
head/sys/kern/sys_process.c
head/sys/sys/proc.h
Modified: head/sys/kern/kern_fork.c
==============================================================================
--- head/sys/kern/kern_fork.c Fri Aug 19 17:55:34 2016 (r304486)
+++ head/sys/kern/kern_fork.c Fri Aug 19 17:57:14 2016 (r304487)
@@ -1074,7 +1074,7 @@ fork_return(struct thread *td, struct tr
* parent's children, do it now.
*/
dbg = p->p_pptr->p_pptr;
- proc_set_traced(p);
+ proc_set_traced(p, true);
CTR2(KTR_PTRACE,
"fork_return: attaching to new child pid %d: oppid %d",
p->p_pid, p->p_oppid);
Modified: head/sys/kern/sys_process.c
==============================================================================
--- head/sys/kern/sys_process.c Fri Aug 19 17:55:34 2016 (r304486)
+++ head/sys/kern/sys_process.c Fri Aug 19 17:57:14 2016 (r304487)
@@ -693,12 +693,13 @@ sys_ptrace(struct thread *td, struct ptr
#endif
void
-proc_set_traced(struct proc *p)
+proc_set_traced(struct proc *p, bool stop)
{
PROC_LOCK_ASSERT(p, MA_OWNED);
p->p_flag |= P_TRACED;
- p->p_flag2 |= P2_PTRACE_FSTP;
+ if (stop)
+ p->p_flag2 |= P2_PTRACE_FSTP;
p->p_ptevents = PTRACE_DEFAULT;
p->p_oppid = p->p_pptr->p_pid;
}
@@ -910,7 +911,7 @@ kern_ptrace(struct thread *td, int req,
switch (req) {
case PT_TRACE_ME:
/* set my trace flag and "owner" so it can read/write me */
- proc_set_traced(p);
+ proc_set_traced(p, false);
if (p->p_flag & P_PPWAIT)
p->p_flag |= P_PPTRACE;
CTR1(KTR_PTRACE, "PT_TRACE_ME: pid %d", p->p_pid);
@@ -927,7 +928,7 @@ kern_ptrace(struct thread *td, int req,
* The old parent is remembered so we can put things back
* on a "detach".
*/
- proc_set_traced(p);
+ proc_set_traced(p, true);
if (p->p_pptr != td->td_proc) {
proc_reparent(p, td->td_proc);
}
Modified: head/sys/sys/proc.h
==============================================================================
--- head/sys/sys/proc.h Fri Aug 19 17:55:34 2016 (r304486)
+++ head/sys/sys/proc.h Fri Aug 19 17:57:14 2016 (r304487)
@@ -1010,7 +1010,7 @@ void proc_linkup(struct proc *p, struct
struct proc *proc_realparent(struct proc *child);
void proc_reap(struct thread *td, struct proc *p, int *status, int options);
void proc_reparent(struct proc *child, struct proc *newparent);
-void proc_set_traced(struct proc *p);
+void proc_set_traced(struct proc *p, bool stop);
struct pstats *pstats_alloc(void);
void pstats_fork(struct pstats *src, struct pstats *dst);
void pstats_free(struct pstats *ps);
More information about the svn-src-head
mailing list