aboutsummaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2013-12-18 01:41:52 +0000
committerMark Johnston <markj@FreeBSD.org>2013-12-18 01:41:52 +0000
commit7159310fa68979b45de779f0e49522d3262eb0a4 (patch)
tree6e1d82eccf41beda77ba33807668e571167cca32 /sys/kern
parentfdc3c84b5be61b1aeadf02ba30c4ef632f107205 (diff)
downloadsrc-7159310fa68979b45de779f0e49522d3262eb0a4.tar.gz
src-7159310fa68979b45de779f0e49522d3262eb0a4.zip
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. MFC after: 1 month
Notes
Notes: svn path=/head/; revision=259535
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_fork.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 3198bd5938be..b3d9c243f942 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -676,12 +676,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 |