git: 79169929f04d - main - 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: Sat, 12 Aug 2023 06:29:08 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=79169929f04d00e51a901d1e4cb377d2475bf660 commit 79169929f04d00e51a901d1e4cb377d2475bf660 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-07-28 00:14:07 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-08-12 06:28:13 +0000 vm_map_protect(): move guard handling at the last phase into an empty dedicated helper Restructure the first phase slightly, to facilitate further changes. Reviewed by: alc, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D41099 --- 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 28c44544c660..dd342752bf6c 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -2722,6 +2722,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: * @@ -2780,12 +2787,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); @@ -2884,10 +2892,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) {