summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/vm/vm_mmap.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index 5965d4a..244877e 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -757,7 +757,7 @@ mincore(td, uap)
end = addr + (vm_size_t)round_page(uap->len);
map = &td->td_proc->p_vmspace->vm_map;
if (end > vm_map_max(map) || end < addr)
- return (EINVAL);
+ return (ENOMEM);
/*
* Address of byte vector
@@ -770,8 +770,10 @@ mincore(td, uap)
RestartScan:
timestamp = map->timestamp;
- if (!vm_map_lookup_entry(map, addr, &entry))
- entry = entry->next;
+ if (!vm_map_lookup_entry(map, addr, &entry)) {
+ vm_map_unlock_read(map);
+ return (ENOMEM);
+ }
/*
* Do this on a map entry basis so that if the pages are not
@@ -784,6 +786,16 @@ RestartScan:
current = current->next) {
/*
+ * check for contiguity
+ */
+ if (current->end < end &&
+ (entry->next == &map->header ||
+ current->next->start > current->end)) {
+ vm_map_unlock_read(map);
+ return (ENOMEM);
+ }
+
+ /*
* ignore submaps (for now) or null objects
*/
if ((current->eflags & MAP_ENTRY_IS_SUB_MAP) ||
OpenPOWER on IntegriCloud