diff options
author | jhb <jhb@FreeBSD.org> | 2010-10-21 19:17:40 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2010-10-21 19:17:40 +0000 |
commit | a41cfdca06b8bd7e2a18e4826efa4b7043be8df0 (patch) | |
tree | 1cee2d1ca3cce75625ff08d21287b1df1ccfd334 /sys/kern/kern_fork.c | |
parent | 118814a9ac4ce1506dcde746c7e878c1cdbb86b7 (diff) | |
download | FreeBSD-src-a41cfdca06b8bd7e2a18e4826efa4b7043be8df0.zip FreeBSD-src-a41cfdca06b8bd7e2a18e4826efa4b7043be8df0.tar.gz |
- When disabling ktracing on a process, free any pending requests that
may be left. This fixes a memory leak that can occur when tracing is
disabled on a process via disabling tracing of a specific file (or if
an I/O error occurs with the tracefile) if the process's next system
call is exit(). The trace disabling code clears p_traceflag, so exit1()
doesn't do any KTRACE-related cleanup leading to the leak. I chose to
make the free'ing of pending records synchronous rather than patching
exit1().
- Move KTRACE-specific logic out of kern_(exec|exit|fork).c and into
kern_ktrace.c instead. Make ktrace_mtx private to kern_ktrace.c as a
result.
MFC after: 1 month
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r-- | sys/kern/kern_fork.c | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index da2c415..126c668 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -645,21 +645,7 @@ again: callout_init(&p2->p_itcallout, CALLOUT_MPSAFE); #ifdef KTRACE - /* - * Copy traceflag and tracefile if enabled. - */ - mtx_lock(&ktrace_mtx); - KASSERT(p2->p_tracevp == NULL, ("new process has a ktrace vnode")); - if (p1->p_traceflag & KTRFAC_INHERIT) { - p2->p_traceflag = p1->p_traceflag; - if ((p2->p_tracevp = p1->p_tracevp) != NULL) { - VREF(p2->p_tracevp); - KASSERT(p1->p_tracecred != NULL, - ("ktrace vnode with no cred")); - p2->p_tracecred = crhold(p1->p_tracecred); - } - } - mtx_unlock(&ktrace_mtx); + ktrprocfork(p1, p2); #endif /* |