From 41795499d11b058714d6f686f5796475bebe1c19 Mon Sep 17 00:00:00 2001 From: dougm Date: Tue, 25 Jun 2019 07:44:37 +0000 Subject: [PATCH] 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 --- sys/vm/vm_map.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 91203170207..38afe6308cc 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -2472,11 +2472,8 @@ vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end, VM_MAP_RANGE_CHECK(map, start, end); - if (vm_map_lookup_entry(map, start, &entry)) { - vm_map_clip_start(map, entry, start); - } else { + if (!vm_map_lookup_entry(map, start, &entry)) entry = entry->next; - } /* * Make a first pass to check for protection violations. @@ -2515,6 +2512,7 @@ vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end, * now will do cow due to allowed write (e.g. debugger sets * breakpoint on text segment) */ + vm_map_clip_start(map, entry, start); for (current = entry; current->start < end; current = current->next) { vm_map_clip_end(map, current, end); -- 2.45.0