mirror of
https://github.com/opnsense/src.git
synced 2026-06-04 14:26:03 -04:00
vm_map_protect(): add VM_MAP_PROTECT_GROWSDOWN flag
which requests to propagate lowest stack segment protection to the grow gap. This seems to be required for Linux emulation. Reported by: dchagin Reviewed by: alc, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D41099
This commit is contained in:
parent
b6037edbd1
commit
90049eabcf
2 changed files with 20 additions and 0 deletions
|
|
@ -2758,6 +2758,7 @@ vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end,
|
|||
vm_map_entry_t entry, first_entry, in_tran, prev_entry;
|
||||
vm_object_t obj;
|
||||
struct ucred *cred;
|
||||
vm_offset_t orig_start;
|
||||
vm_prot_t check_prot, max_prot, old_prot;
|
||||
int rv;
|
||||
|
||||
|
|
@ -2769,8 +2770,10 @@ vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end,
|
|||
!CONTAINS_BITS(new_maxprot, new_prot))
|
||||
return (KERN_OUT_OF_BOUNDS);
|
||||
|
||||
orig_start = start;
|
||||
again:
|
||||
in_tran = NULL;
|
||||
start = orig_start;
|
||||
vm_map_lock(map);
|
||||
|
||||
if ((map->flags & MAP_WXORX) != 0 &&
|
||||
|
|
@ -2793,6 +2796,22 @@ again:
|
|||
if (!vm_map_lookup_entry(map, start, &first_entry))
|
||||
first_entry = vm_map_entry_succ(first_entry);
|
||||
|
||||
if ((flags & VM_MAP_PROTECT_GROWSDOWN) != 0 &&
|
||||
(first_entry->eflags & MAP_ENTRY_GROWS_DOWN) != 0) {
|
||||
/*
|
||||
* Handle Linux's PROT_GROWSDOWN flag.
|
||||
* It means that protection is applied down to the
|
||||
* whole stack, including the specified range of the
|
||||
* mapped region, and the grow down region (AKA
|
||||
* guard).
|
||||
*/
|
||||
while (!CONTAINS_BITS(first_entry->eflags,
|
||||
MAP_ENTRY_GUARD | MAP_ENTRY_STACK_GAP_DN) &&
|
||||
first_entry != vm_map_entry_first(map))
|
||||
first_entry = vm_map_entry_pred(first_entry);
|
||||
start = first_entry->start;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a first pass to check for protection violations.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -522,6 +522,7 @@ vm_map_entry_succ(vm_map_entry_t entry)
|
|||
|
||||
#define VM_MAP_PROTECT_SET_PROT 0x0001
|
||||
#define VM_MAP_PROTECT_SET_MAXPROT 0x0002
|
||||
#define VM_MAP_PROTECT_GROWSDOWN 0x0004
|
||||
|
||||
int vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end,
|
||||
vm_prot_t new_prot, vm_prot_t new_maxprot, int flags);
|
||||
|
|
|
|||
Loading…
Reference in a new issue