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_exit.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_exit.c')
-rw-r--r-- | sys/kern/kern_exit.c | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 029f1c3..31389e1 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -121,10 +121,6 @@ exit1(struct thread *td, int rv) struct proc *p, *nq, *q; struct vnode *vtmp; struct vnode *ttyvp = NULL; -#ifdef KTRACE - struct vnode *tracevp; - struct ucred *tracecred; -#endif struct plimit *plim; int locked; @@ -356,33 +352,7 @@ exit1(struct thread *td, int rv) if (ttyvp != NULL) vrele(ttyvp); #ifdef KTRACE - /* - * Disable tracing, then drain any pending records and release - * the trace file. - */ - if (p->p_traceflag != 0) { - PROC_LOCK(p); - mtx_lock(&ktrace_mtx); - p->p_traceflag = 0; - mtx_unlock(&ktrace_mtx); - PROC_UNLOCK(p); - ktrprocexit(td); - PROC_LOCK(p); - mtx_lock(&ktrace_mtx); - tracevp = p->p_tracevp; - p->p_tracevp = NULL; - tracecred = p->p_tracecred; - p->p_tracecred = NULL; - mtx_unlock(&ktrace_mtx); - PROC_UNLOCK(p); - if (tracevp != NULL) { - locked = VFS_LOCK_GIANT(tracevp->v_mount); - vrele(tracevp); - VFS_UNLOCK_GIANT(locked); - } - if (tracecred != NULL) - crfree(tracecred); - } + ktrprocexit(td); #endif /* * Release reference to text vnode |