summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_map.c
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2004-04-24 03:46:44 +0000
committeralc <alc@FreeBSD.org>2004-04-24 03:46:44 +0000
commitff037b922053b9017606ca7f367e03a0b15b0436 (patch)
tree5e4c7fcfc99f16405827827ff0cce7258c744397 /sys/vm/vm_map.c
parent37a55c7ec422afd8d71d38197362659be6a4a63b (diff)
downloadFreeBSD-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/vm/vm_map.c')
-rw-r--r--sys/vm/vm_map.c9
1 files changed, 5 insertions, 4 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),
OpenPOWER on IntegriCloud