PR kern/50985: use the runtime limits of the vmspace in range_test()

instead of the compile time defaults for it.
This commit is contained in:
martin 2016-05-24 20:20:57 +00:00
parent 3be6f3a78a
commit 8ae1d7229f
1 changed files with 18 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_mmap.c,v 1.157 2016/05/22 14:26:09 christos Exp $ */
/* $NetBSD: uvm_mmap.c,v 1.158 2016/05/24 20:20:57 martin Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.157 2016/05/22 14:26:09 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.158 2016/05/24 20:20:57 martin Exp $");
#include "opt_compat_netbsd.h"
#include "opt_pax.h"
@ -67,10 +67,10 @@ static int uvm_mmap(struct vm_map *, vaddr_t *, vsize_t, vm_prot_t, vm_prot_t,
int, int, struct uvm_object *, voff_t, vsize_t);
static int
range_test(vaddr_t addr, vsize_t size, bool ismmap)
range_test(struct vm_map *map, vaddr_t addr, vsize_t size, bool ismmap)
{
vaddr_t vm_min_address = VM_MIN_ADDRESS;
vaddr_t vm_max_address = VM_MAXUSER_ADDRESS;
vaddr_t vm_min_address = vm_map_min(map);
vaddr_t vm_max_address = vm_map_max(map);
vaddr_t eaddr = addr + size;
int res = 0;
@ -353,7 +353,7 @@ sys_mmap(struct lwp *l, const struct sys_mmap_args *uap, register_t *retval)
if (addr & PAGE_MASK)
return (EINVAL);
error = range_test(addr, size, true);
error = range_test(&p->p_vmspace->vm_map, addr, size, true);
if (error) {
return error;
}
@ -480,16 +480,16 @@ sys___msync13(struct lwp *l, const struct sys___msync13_args *uap,
size += pageoff;
size = (vsize_t)round_page(size);
error = range_test(addr, size, false);
if (error)
return error;
/*
* get map
*/
map = &p->p_vmspace->vm_map;
error = range_test(map, addr, size, false);
if (error)
return error;
/*
* XXXCDC: do we really need this semantic?
*
@ -566,12 +566,12 @@ sys_munmap(struct lwp *l, const struct sys_munmap_args *uap, register_t *retval)
if (size == 0)
return (0);
error = range_test(addr, size, false);
map = &p->p_vmspace->vm_map;
error = range_test(map, addr, size, false);
if (error)
return error;
map = &p->p_vmspace->vm_map;
/*
* interesting system call semantic: make sure entire range is
* allocated before allowing an unmap.
@ -627,7 +627,7 @@ sys_mprotect(struct lwp *l, const struct sys_mprotect_args *uap,
size += pageoff;
size = round_page(size);
error = range_test(addr, size, false);
error = range_test(&p->p_vmspace->vm_map, addr, size, false);
if (error)
return error;
@ -668,7 +668,7 @@ sys_minherit(struct lwp *l, const struct sys_minherit_args *uap,
size += pageoff;
size = (vsize_t)round_page(size);
error = range_test(addr, size, false);
error = range_test(&p->p_vmspace->vm_map, addr, size, false);
if (error)
return error;
@ -709,7 +709,7 @@ sys_madvise(struct lwp *l, const struct sys_madvise_args *uap,
size += pageoff;
size = (vsize_t)round_page(size);
error = range_test(addr, size, false);
error = range_test(&p->p_vmspace->vm_map, addr, size, false);
if (error)
return error;
@ -809,7 +809,7 @@ sys_mlock(struct lwp *l, const struct sys_mlock_args *uap, register_t *retval)
size += pageoff;
size = (vsize_t)round_page(size);
error = range_test(addr, size, false);
error = range_test(&p->p_vmspace->vm_map, addr, size, false);
if (error)
return error;
@ -860,7 +860,7 @@ sys_munlock(struct lwp *l, const struct sys_munlock_args *uap,
size += pageoff;
size = (vsize_t)round_page(size);
error = range_test(addr, size, false);
error = range_test(&p->p_vmspace->vm_map, addr, size, false);
if (error)
return error;