git: f28d489aaaa4 - stable/13 - vm_map_protect(): move guard handling at the last phase into an empty dedicated helper
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 25 Aug 2023 01:08:32 UTC
The branch stable/13 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=f28d489aaaa417afe984a096dfbfecbfb6b2a695
commit f28d489aaaa417afe984a096dfbfecbfb6b2a695
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-07-28 00:14:07 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-08-25 01:06:44 +0000
vm_map_protect(): move guard handling at the last phase into an empty dedicated helper
(cherry picked from commit 79169929f04d00e51a901d1e4cb377d2475bf660)
---
sys/vm/vm_map.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index d4e4f2c89679..d443c320b799 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -2716,6 +2716,13 @@ vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot,
VM_OBJECT_RUNLOCK(object);
}
+static void
+vm_map_protect_guard(vm_map_entry_t entry, vm_prot_t new_prot,
+ vm_prot_t new_maxprot, int flags)
+{
+ MPASS((entry->eflags & MAP_ENTRY_GUARD) != 0);
+}
+
/*
* vm_map_protect:
*
@@ -2774,12 +2781,13 @@ again:
check_prot |= new_maxprot;
for (entry = first_entry; entry->start < end;
entry = vm_map_entry_succ(entry)) {
- if ((entry->eflags & MAP_ENTRY_GUARD) != 0)
- continue;
if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) != 0) {
vm_map_unlock(map);
return (KERN_INVALID_ARGUMENT);
}
+ if ((entry->eflags & MAP_ENTRY_GUARD) != 0) {
+ continue;
+ }
if (!CONTAINS_BITS(entry->max_protection, check_prot)) {
vm_map_unlock(map);
return (KERN_PROTECTION_FAILURE);
@@ -2879,10 +2887,15 @@ again:
entry->start < end;
vm_map_try_merge_entries(map, prev_entry, entry),
prev_entry = entry, entry = vm_map_entry_succ(entry)) {
- if (rv != KERN_SUCCESS ||
- (entry->eflags & MAP_ENTRY_GUARD) != 0)
+ if (rv != KERN_SUCCESS)
continue;
+ if ((entry->eflags & MAP_ENTRY_GUARD) != 0) {
+ vm_map_protect_guard(entry, new_prot, new_maxprot,
+ flags);
+ continue;
+ }
+
old_prot = entry->protection;
if ((flags & VM_MAP_PROTECT_SET_MAXPROT) != 0) {