diff options
author | markj <markj@FreeBSD.org> | 2014-03-18 00:29:33 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2014-03-18 00:29:33 +0000 |
commit | 437134881a4bc49d0dadada0235ad48146cd62b6 (patch) | |
tree | 56dde2981e33f65ff0e9647708ba151c41df589e /sys/kern/kern_fork.c | |
parent | f674f353eee112692d83f39cb1f07f1cbb25380a (diff) | |
download | FreeBSD-src-437134881a4bc49d0dadada0235ad48146cd62b6.zip FreeBSD-src-437134881a4bc49d0dadada0235ad48146cd62b6.tar.gz |
MFC r259535:
The fasttrap fork handler is responsible for removing tracepoints in the
child process that were inherited from its parent. However, this should
not be done in the case of a vfork, since the fork handler ends up removing
the tracepoints from the shared vm space, and userland DTrace probes in the
parent will no longer fire as a result.
Now the child of a vfork may trigger userland DTrace probes enabled in its
parent, so modify the fasttrap probe handler to handle this case and handle
the child process in the same way that it would handle the traced process.
In particular, if once traces function foo() in a process that vforks, and
the child calls foo(), fasttrap will treat this call as having come from the
parent. This is the behaviour of the upstream code.
While here, add #ifdef guards to some code that isn't present upstream.
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r-- | sys/kern/kern_fork.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 04a7eba..76605f4 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -684,12 +684,12 @@ do_fork(struct thread *td, int flags, struct proc *p2, struct thread *td2, #ifdef KDTRACE_HOOKS /* - * Tell the DTrace fasttrap provider about the new process - * if it has registered an interest. We have to do this only after - * p_state is PRS_NORMAL since the fasttrap module will use pfind() - * later on. + * Tell the DTrace fasttrap provider about the new process so that any + * tracepoints inherited from the parent can be removed. We have to do + * this only after p_state is PRS_NORMAL since the fasttrap module will + * use pfind() later on. */ - if (dtrace_fasttrap_fork) + if ((flags & RFMEM) == 0 && dtrace_fasttrap_fork) dtrace_fasttrap_fork(p1, p2); #endif if ((p1->p_flag & (P_TRACED | P_FOLLOWFORK)) == (P_TRACED | |