Properly lock accesses to p_tracep and p_traceflag. Also make a few

ktrace-only things #ifdef KTRACE that were not before.
This commit is contained in:
John Baldwin 2002-06-07 05:41:27 +00:00
parent 80ad7ca938
commit 6c84de02e0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=97997
3 changed files with 27 additions and 3 deletions

View File

@ -135,7 +135,10 @@ execve(td, uap)
int (*img_first)(struct image_params *);
struct pargs *oldargs, *newargs = NULL;
struct procsig *oldprocsig, *newprocsig;
struct vnode *tracevp = NULL, *textvp = NULL;
#ifdef KTRACE
struct vnode *tracevp = NULL;
#endif
struct vnode *textvp = NULL;
imgp = &image_params;
@ -369,11 +372,15 @@ execve(td, uap)
* we do not regain any tracing during a possible block.
*/
setsugid(p);
#ifdef KTRACE
if (p->p_tracep && suser_cred(oldcred, PRISON_ROOT)) {
mtx_lock(&ktrace_mtx);
p->p_traceflag = 0;
tracevp = p->p_tracep;
p->p_tracep = NULL;
mtx_unlock(&ktrace_mtx);
}
#endif
/* Make sure file descriptors 0..2 are in use. */
error = fdcheckstd(td);
if (error != 0)
@ -475,8 +482,10 @@ execve(td, uap)
*/
if (textvp != NULL)
vrele(textvp);
#ifdef KTRACE
if (tracevp != NULL)
vrele(tracevp);
#endif
pargs_drop(oldargs);
exec_fail_dealloc:

View File

@ -64,6 +64,9 @@
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/jail.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <vm/vm.h>
#include <vm/vm_extern.h>
@ -296,9 +299,11 @@ exit1(td, rv)
* release trace file
*/
PROC_LOCK(p);
mtx_lock(&ktrace_mtx);
p->p_traceflag = 0; /* don't trace the vrele() */
tracevp = p->p_tracep;
p->p_tracep = NULL;
mtx_unlock(&ktrace_mtx);
PROC_UNLOCK(p);
if (tracevp != NULL)
vrele(tracevp);

View File

@ -34,6 +34,8 @@
* $FreeBSD$
*/
#include "opt_ktrace.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@ -49,6 +51,10 @@
#include <sys/sx.h>
#include <sys/user.h>
#include <sys/jail.h>
#ifdef KTRACE
#include <sys/uio.h>
#include <sys/ktrace.h>
#endif
#include <vm/vm.h>
#include <vm/pmap.h>
@ -643,8 +649,13 @@ fill_kinfo_proc(p, kp)
PROC_LOCK_ASSERT(p, MA_OWNED);
kp->ki_addr =/* p->p_addr; */0; /* XXXKSE */
kp->ki_args = p->p_args;
kp->ki_tracep = p->p_tracep;
kp->ki_textvp = p->p_textvp;
#ifdef KTRACE
kp->ki_tracep = p->p_tracep;
mtx_lock(&ktrace_mtx);
kp->ki_traceflag = p->p_traceflag;
mtx_unlock(&ktrace_mtx);
#endif
kp->ki_fd = p->p_fd;
kp->ki_vmspace = p->p_vmspace;
if (p->p_ucred) {
@ -696,7 +707,6 @@ fill_kinfo_proc(p, kp)
kp->ki_stat = p->p_stat;
kp->ki_sflag = p->p_sflag;
kp->ki_swtime = p->p_swtime;
kp->ki_traceflag = p->p_traceflag;
kp->ki_pid = p->p_pid;
/* vvv XXXKSE */
bintime2timeval(&p->p_runtime, &tv);