Lock the target process in procfs_doproc*regs() for p_candebug and while

reading/writing the registers.
This commit is contained in:
jhb 2002-04-13 23:14:08 +00:00
parent 2c33307035
commit 04f22cf811
3 changed files with 23 additions and 9 deletions

View File

@ -68,8 +68,11 @@ procfs_doprocdbregs(PFS_FILL_ARGS)
char *kv;
int kl;
if (p_candebug(td->td_proc, p))
PROC_LOCK(p);
if (p_candebug(td->td_proc, p) != 0) {
PROC_UNLOCK(p);
return (EPERM);
}
kl = sizeof(r);
kv = (char *) &r;
@ -78,7 +81,7 @@ procfs_doprocdbregs(PFS_FILL_ARGS)
if (kl > uio->uio_resid)
kl = uio->uio_resid;
PHOLD(p);
_PHOLD(p);
if (kl < 0)
error = EINVAL;
else
@ -93,7 +96,8 @@ procfs_doprocdbregs(PFS_FILL_ARGS)
/* XXXKSE: */
error = proc_write_dbregs(FIRST_THREAD_IN_PROC(p), &r);
}
PRELE(p);
_PRELE(p);
PROC_UNLOCK(p);
uio->uio_offset = 0;
return (error);

View File

@ -62,8 +62,11 @@ procfs_doprocfpregs(PFS_FILL_ARGS)
char *kv;
int kl;
if (p_candebug(td->td_proc, p))
PROC_LOCK(p);
if (p_candebug(td->td_proc, p)) {
PROC_UNLOCK(p);
return (EPERM);
}
kl = sizeof(r);
kv = (char *) &r;
@ -72,7 +75,7 @@ procfs_doprocfpregs(PFS_FILL_ARGS)
if (kl > uio->uio_resid)
kl = uio->uio_resid;
PHOLD(p);
_PHOLD(p);
if (kl < 0)
error = EINVAL;
else
@ -87,7 +90,8 @@ procfs_doprocfpregs(PFS_FILL_ARGS)
/* XXXKSE: */
error = proc_write_fpregs(FIRST_THREAD_IN_PROC(p), &r);
}
PRELE(p);
_PRELE(p);
PROC_UNLOCK(p);
uio->uio_offset = 0;
return (error);

View File

@ -62,8 +62,11 @@ procfs_doprocregs(PFS_FILL_ARGS)
char *kv;
int kl;
if (p_candebug(td->td_proc, p))
PROC_LOCK(p);
if (p_candebug(td->td_proc, p)) {
PROC_UNLOCK(p);
return (EPERM);
}
kl = sizeof(r);
kv = (char *) &r;
@ -72,7 +75,8 @@ procfs_doprocregs(PFS_FILL_ARGS)
if (kl > uio->uio_resid)
kl = uio->uio_resid;
PHOLD(p);
_PHOLD(p);
PROC_UNLOCK(p);
if (kl < 0)
error = EINVAL;
else
@ -80,6 +84,7 @@ procfs_doprocregs(PFS_FILL_ARGS)
error = proc_read_regs(FIRST_THREAD_IN_PROC(p), &r);
if (error == 0)
error = uiomove(kv, kl, uio);
PROC_LOCK(p);
if (error == 0 && uio->uio_rw == UIO_WRITE) {
if (p->p_stat != SSTOP)
error = EBUSY;
@ -87,7 +92,8 @@ procfs_doprocregs(PFS_FILL_ARGS)
/* XXXKSE: */
error = proc_write_regs(FIRST_THREAD_IN_PROC(p), &r);
}
PRELE(p);
_PRELE(p);
PROC_UNLOCK(p);
uio->uio_offset = 0;
return (error);