1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-20 11:11:24 +00:00

Keep the process locked when calling ktrops() or ktrsetchildren() instead

of dropping the lock only to immediately reacquire it.
This commit is contained in:
John Baldwin 2010-08-17 21:34:19 +00:00
parent 187278cadc
commit fe41d17ab2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=211439

View File

@ -741,7 +741,6 @@ ktrace(td, uap)
PROC_UNLOCK(p);
continue;
}
PROC_UNLOCK(p);
nfound++;
if (descend)
ret |= ktrsetchildren(td, p, ops, facs, vp);
@ -758,18 +757,13 @@ ktrace(td, uap)
* by pid
*/
p = pfind(uap->pid);
if (p == NULL) {
sx_sunlock(&proctree_lock);
if (p == NULL)
error = ESRCH;
goto done;
}
error = p_cansee(td, p);
/*
* The slock of the proctree lock will keep this process
* from going away, so unlocking the proc here is ok.
*/
PROC_UNLOCK(p);
else
error = p_cansee(td, p);
if (error) {
if (p != NULL)
PROC_UNLOCK(p);
sx_sunlock(&proctree_lock);
goto done;
}
@ -841,11 +835,16 @@ ktrops(td, p, ops, facs, vp)
struct vnode *tracevp = NULL;
struct ucred *tracecred = NULL;
PROC_LOCK(p);
PROC_LOCK_ASSERT(p, MA_OWNED);
if (!ktrcanset(td, p)) {
PROC_UNLOCK(p);
return (0);
}
if (p->p_flag & P_WEXIT) {
/* If the process is exiting, just ignore it. */
PROC_UNLOCK(p);
return (1);
}
mtx_lock(&ktrace_mtx);
if (ops == KTROP_SET) {
if (p->p_tracevp != vp) {
@ -900,6 +899,7 @@ ktrsetchildren(td, top, ops, facs, vp)
register int ret = 0;
p = top;
PROC_LOCK_ASSERT(p, MA_OWNED);
sx_assert(&proctree_lock, SX_LOCKED);
for (;;) {
ret |= ktrops(td, p, ops, facs, vp);
@ -919,6 +919,7 @@ ktrsetchildren(td, top, ops, facs, vp)
}
p = p->p_pptr;
}
PROC_LOCK(p);
}
/*NOTREACHED*/
}