diff options
author | jake <jake@FreeBSD.org> | 2002-09-21 22:07:17 +0000 |
---|---|---|
committer | jake <jake@FreeBSD.org> | 2002-09-21 22:07:17 +0000 |
commit | 2b71a04b1e46f7a598269467b77323fad8f53189 (patch) | |
tree | 5a29a2272e4b65acf468c2f877289cf21786b297 /sys/vm/vm_mmap.c | |
parent | 5ea401e1a679065a9e8506758d9735855dc7a419 (diff) | |
download | FreeBSD-src-2b71a04b1e46f7a598269467b77323fad8f53189.zip FreeBSD-src-2b71a04b1e46f7a598269467b77323fad8f53189.tar.gz |
Use the fields in the sysentvec and in the vm map header in place of the
constants VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS, USRSTACK and PS_STRINGS.
This is mainly so that they can be variable even for the native abi, based
on different machine types. Get stack protections from the sysentvec too.
This makes it trivial to map the stack non-executable for certain abis, on
machines that support it.
Diffstat (limited to 'sys/vm/vm_mmap.c')
-rw-r--r-- | sys/vm/vm_mmap.c | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index b9894a4..42446fb 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -257,12 +257,9 @@ mmap(td, uap) if (addr & PAGE_MASK) return (EINVAL); /* Address range must be all in user VM space. */ - if (VM_MAXUSER_ADDRESS > 0 && addr + size > VM_MAXUSER_ADDRESS) + if (addr < vm_map_min(&vms->vm_map) || + addr + size > vm_map_max(&vms->vm_map)) return (EINVAL); -#ifndef __i386__ - if (VM_MIN_ADDRESS > 0 && addr < VM_MIN_ADDRESS) - return (EINVAL); -#endif if (addr + size < addr) return (EINVAL); } @@ -611,16 +608,11 @@ munmap(td, uap) return (0); /* - * Check for illegal addresses. Watch out for address wrap... Note - * that VM_*_ADDRESS are not constants due to casts (argh). + * Check for illegal addresses. Watch out for address wrap... */ - if (VM_MAXUSER_ADDRESS > 0 && addr + size > VM_MAXUSER_ADDRESS) - return (EINVAL); -#ifndef __i386__ - if (VM_MIN_ADDRESS > 0 && addr < VM_MIN_ADDRESS) - return (EINVAL); -#endif map = &td->td_proc->p_vmspace->vm_map; + if (addr < vm_map_min(map) || addr + size > vm_map_max(map)) + return (EINVAL); /* * Make sure entire range is allocated. */ @@ -749,6 +741,7 @@ madvise(td, uap) struct madvise_args *uap; { vm_offset_t start, end; + vm_map_t map; /* * Check for illegal behavior @@ -759,13 +752,10 @@ madvise(td, uap) * Check for illegal addresses. Watch out for address wrap... Note * that VM_*_ADDRESS are not constants due to casts (argh). */ - if (VM_MAXUSER_ADDRESS > 0 && - ((vm_offset_t) uap->addr + uap->len) > VM_MAXUSER_ADDRESS) - return (EINVAL); -#ifndef __i386__ - if (VM_MIN_ADDRESS > 0 && uap->addr < VM_MIN_ADDRESS) + map = &td->td_proc->p_vmspace->vm_map; + if ((vm_offset_t)uap->addr < vm_map_min(map) || + (vm_offset_t)uap->addr + uap->len > vm_map_max(map)) return (EINVAL); -#endif if (((vm_offset_t) uap->addr + uap->len) < (vm_offset_t) uap->addr) return (EINVAL); @@ -776,8 +766,7 @@ madvise(td, uap) start = trunc_page((vm_offset_t) uap->addr); end = round_page((vm_offset_t) uap->addr + uap->len); - if (vm_map_madvise(&td->td_proc->p_vmspace->vm_map, start, end, - uap->behav)) + if (vm_map_madvise(map, start, end, uap->behav)) return (EINVAL); return (0); } @@ -817,9 +806,8 @@ mincore(td, uap) */ first_addr = addr = trunc_page((vm_offset_t) uap->addr); end = addr + (vm_size_t)round_page(uap->len); - if (VM_MAXUSER_ADDRESS > 0 && end > VM_MAXUSER_ADDRESS) - return (EINVAL); - if (end < addr) + map = &td->td_proc->p_vmspace->vm_map; + if (end > vm_map_max(map) || end < addr) return (EINVAL); /* @@ -828,7 +816,6 @@ mincore(td, uap) vec = uap->vec; mtx_lock(&Giant); - map = &td->td_proc->p_vmspace->vm_map; pmap = vmspace_pmap(td->td_proc->p_vmspace); vm_map_lock_read(map); |