diff options
author | alc <alc@FreeBSD.org> | 2004-04-24 03:46:44 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2004-04-24 03:46:44 +0000 |
commit | ff037b922053b9017606ca7f367e03a0b15b0436 (patch) | |
tree | 5e4c7fcfc99f16405827827ff0cce7258c744397 /sys | |
parent | 37a55c7ec422afd8d71d38197362659be6a4a63b (diff) | |
download | FreeBSD-src-ff037b922053b9017606ca7f367e03a0b15b0436.zip FreeBSD-src-ff037b922053b9017606ca7f367e03a0b15b0436.tar.gz |
In cases where a file was resident in memory mmap(..., PROT_NONE, ...)
would actually map the file with read access enabled. According to
http://www.opengroup.org/onlinepubs/007904975/functions/mmap.html this is
an error. Similarly, an madvise(..., MADV_WILLNEED) would enable read
access on a virtual address range that was PROT_NONE.
The solution implemented herein is (1) to pass a vm_prot_t to
vm_map_pmap_enter() describing the allowed access and (2) to make
vm_map_pmap_enter() responsible for understanding the limitations of
pmap_enter_quick().
Submitted by: "Mark W. Krentel" <krentel@dreamscape.com>
PR: kern/64573
Diffstat (limited to 'sys')
-rw-r--r-- | sys/vm/vm_map.c | 9 | ||||
-rw-r--r-- | sys/vm/vm_map.h | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index fea65e5..71e6d6a 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -877,7 +877,7 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset, #endif if (cow & (MAP_PREFAULT|MAP_PREFAULT_PARTIAL)) { - vm_map_pmap_enter(map, start, + vm_map_pmap_enter(map, start, prot, object, OFF_TO_IDX(offset), end - start, cow & MAP_PREFAULT_PARTIAL); } @@ -1243,19 +1243,19 @@ vm_map_submap( /* * vm_map_pmap_enter: * - * Preload the mappings for the given object into the specified + * Preload read-only mappings for the given object into the specified * map. This eliminates the soft faults on process startup and * immediately after an mmap(2). */ void -vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, +vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, vm_object_t object, vm_pindex_t pindex, vm_size_t size, int flags) { vm_offset_t tmpidx; int psize; vm_page_t p, mpte; - if (object == NULL) + if ((prot & VM_PROT_READ) == 0 || object == NULL) return; mtx_lock(&Giant); VM_OBJECT_LOCK(object); @@ -1547,6 +1547,7 @@ vm_map_madvise( if (behav == MADV_WILLNEED) { vm_map_pmap_enter(map, useStart, + current->protection, current->object.vm_object, pindex, (count << PAGE_SHIFT), diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index 51e66ca..502b5b9 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -333,7 +333,7 @@ int vm_map_lookup (vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_obje vm_pindex_t *, vm_prot_t *, boolean_t *); void vm_map_lookup_done (vm_map_t, vm_map_entry_t); boolean_t vm_map_lookup_entry (vm_map_t, vm_offset_t, vm_map_entry_t *); -void vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, +void vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, vm_object_t object, vm_pindex_t pindex, vm_size_t size, int flags); int vm_map_protect (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t, boolean_t); int vm_map_remove (vm_map_t, vm_offset_t, vm_offset_t); |