summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_mmap.c
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1995-05-18 02:59:26 +0000
committerdg <dg@FreeBSD.org>1995-05-18 02:59:26 +0000
commit56d21b42187f0f163a5c67c2126117d7ff8bc6fc (patch)
tree7392d140844fbfda67ab8ff22f1dafd98f01ae78 /sys/vm/vm_mmap.c
parent2831e6ec6177d558463cf22f90a0a04d21b4934b (diff)
downloadFreeBSD-src-56d21b42187f0f163a5c67c2126117d7ff8bc6fc.zip
FreeBSD-src-56d21b42187f0f163a5c67c2126117d7ff8bc6fc.tar.gz
Accessing pages beyond the end of a mapped file results in internal
inconsistencies in the VM system that eventually lead to a panic. These changes fix the behavior to conform to the behavior in SunOS, which is to deny faults to pages beyond the EOF (returning SIGBUS). Internally, this is implemented by requiring faults to be within the object size boundaries. These changes exposed another bug, namely that passing in an offset to mmap when trying to map an unnamed anonymous region also results in internal inconsistencies. In this case, the offset is forced to zero. Reviewed by: John Dyson and others
Diffstat (limited to 'sys/vm/vm_mmap.c')
-rw-r--r--sys/vm/vm_mmap.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index a4a9a62..381603e 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -38,7 +38,7 @@
* from: Utah $Hdr: vm_mmap.c 1.6 91/10/21$
*
* @(#)vm_mmap.c 8.4 (Berkeley) 1/12/94
- * $Id: vm_mmap.c,v 1.21 1995/03/25 17:44:03 davidg Exp $
+ * $Id: vm_mmap.c,v 1.22 1995/04/16 12:56:18 davidg Exp $
*/
/*
@@ -641,9 +641,14 @@ vm_mmap(map, addr, size, prot, maxprot, flags, handle, foff)
* a reference to ensure continued existance of the object. (XXX the
* exception is to appease the pageout daemon)
*/
- if (flags & MAP_ANON)
+ if (flags & MAP_ANON) {
type = PG_DFLT;
- else {
+ /*
+ * Unnamed anonymous regions always start at 0.
+ */
+ if (handle == 0)
+ foff = 0;
+ } else {
vp = (struct vnode *) handle;
if (vp->v_type == VCHR) {
type = PG_DEVICE;
OpenPOWER on IntegriCloud