summaryrefslogtreecommitdiffstats
path: root/sys/fs/procfs
diff options
context:
space:
mode:
authordyson <dyson@FreeBSD.org>1996-06-11 23:52:27 +0000
committerdyson <dyson@FreeBSD.org>1996-06-11 23:52:27 +0000
commit94ca54ddd28985e6cbd836d5352b0cd5dfdeb4ff (patch)
tree74deff0db4cf6ea826ac408497cbc503af50cbf4 /sys/fs/procfs
parent1ad26364cdbfce3d346200a3d9879eea363f25ba (diff)
downloadFreeBSD-src-94ca54ddd28985e6cbd836d5352b0cd5dfdeb4ff.zip
FreeBSD-src-94ca54ddd28985e6cbd836d5352b0cd5dfdeb4ff.tar.gz
Properly lock the vm space when accessing the memory in a process. This
fix could solve some "interesting" problems that could happen during process rundown.
Diffstat (limited to 'sys/fs/procfs')
-rw-r--r--sys/fs/procfs/procfs_mem.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/sys/fs/procfs/procfs_mem.c b/sys/fs/procfs/procfs_mem.c
index 04b3a37..34d7f35 100644
--- a/sys/fs/procfs/procfs_mem.c
+++ b/sys/fs/procfs/procfs_mem.c
@@ -37,7 +37,7 @@
*
* @(#)procfs_mem.c 8.4 (Berkeley) 1/21/94
*
- * $Id: procfs_mem.c,v 1.16 1996/01/24 18:41:06 peter Exp $
+ * $Id: procfs_mem.c,v 1.17 1996/01/25 06:05:38 peter Exp $
*/
/*
@@ -73,6 +73,17 @@ procfs_rwmem(p, uio)
{
int error;
int writing;
+ struct vmspace *vm;
+
+ /*
+ * if the vmspace is in the midst of being deallocated or the
+ * process is exiting, don't try to grab anything. The page table
+ * usage in that process can be messed up.
+ */
+ vm = p->p_vmspace;
+ if ((p->p_flag & P_WEXIT) || (vm->vm_refcnt < 1))
+ return EFAULT;
+ ++vm->vm_refcnt;
writing = uio->uio_rw == UIO_WRITE;
@@ -144,7 +155,7 @@ procfs_rwmem(p, uio)
/*
* The map we want...
*/
- map = &p->p_vmspace->vm_map;
+ map = &vm->vm_map;
/*
* Check the permissions for the area we're interested
@@ -230,6 +241,7 @@ procfs_rwmem(p, uio)
VM_PROT_READ|VM_PROT_EXECUTE, 0);
} while (error == 0 && uio->uio_resid > 0);
+ vmspace_free(vm);
return (error);
}
OpenPOWER on IntegriCloud