summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2002-04-13 23:14:08 +0000
committerjhb <jhb@FreeBSD.org>2002-04-13 23:14:08 +0000
commit04f22cf81107fa960152dc835a2290c72cf93264 (patch)
treedbac7ac030e9a8f6b77e3a986520450b70f01a26 /sys/fs
parent2c33307035d86657e961fdf238490fc7633b59be (diff)
downloadFreeBSD-src-04f22cf81107fa960152dc835a2290c72cf93264.zip
FreeBSD-src-04f22cf81107fa960152dc835a2290c72cf93264.tar.gz
Lock the target process in procfs_doproc*regs() for p_candebug and while
reading/writing the registers.
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/procfs/procfs_dbregs.c10
-rw-r--r--sys/fs/procfs/procfs_fpregs.c10
-rw-r--r--sys/fs/procfs/procfs_regs.c12
3 files changed, 23 insertions, 9 deletions
diff --git a/sys/fs/procfs/procfs_dbregs.c b/sys/fs/procfs/procfs_dbregs.c
index e5fc59e..29ff71b 100644
--- a/sys/fs/procfs/procfs_dbregs.c
+++ b/sys/fs/procfs/procfs_dbregs.c
@@ -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);
diff --git a/sys/fs/procfs/procfs_fpregs.c b/sys/fs/procfs/procfs_fpregs.c
index 8501d9a..caabe49 100644
--- a/sys/fs/procfs/procfs_fpregs.c
+++ b/sys/fs/procfs/procfs_fpregs.c
@@ -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);
diff --git a/sys/fs/procfs/procfs_regs.c b/sys/fs/procfs/procfs_regs.c
index 77cd847..3c0a700 100644
--- a/sys/fs/procfs/procfs_regs.c
+++ b/sys/fs/procfs/procfs_regs.c
@@ -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);
OpenPOWER on IntegriCloud