vm_map_protect may return an INVALID_ARGUMENT or PROTECTION_FAILURE

error response after clipping the first map entry in the region to be
reserved. This creates a pair of matching entries that should have
been "simplified" back into one, or never created. This change defers
the clipping of that entry until those two vm_map_protect failure
cases have been ruled out.

Reviewed by: alc
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D20711
This commit is contained in:
dougm 2019-06-25 07:44:37 +00:00
parent 78b055cc38
commit 41795499d1

View File

@ -2472,11 +2472,8 @@ again:
VM_MAP_RANGE_CHECK(map, start, end); VM_MAP_RANGE_CHECK(map, start, end);
if (vm_map_lookup_entry(map, start, &entry)) { if (!vm_map_lookup_entry(map, start, &entry))
vm_map_clip_start(map, entry, start);
} else {
entry = entry->next; entry = entry->next;
}
/* /*
* Make a first pass to check for protection violations. * Make a first pass to check for protection violations.
@ -2515,6 +2512,7 @@ again:
* now will do cow due to allowed write (e.g. debugger sets * now will do cow due to allowed write (e.g. debugger sets
* breakpoint on text segment) * breakpoint on text segment)
*/ */
vm_map_clip_start(map, entry, start);
for (current = entry; current->start < end; current = current->next) { for (current = entry; current->start < end; current = current->next) {
vm_map_clip_end(map, current, end); vm_map_clip_end(map, current, end);