NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/50985: uvm_mmap.c::range_test should use runtime limits of the vmspace?



The following reply was made to PR kern/50985; it has been noted by GNATS.

From: Martin Husemann <martin%duskware.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: Chuck Silvers <chs%NetBSD.org@localhost>
Subject: Re: kern/50985: uvm_mmap.c::range_test should use runtime limits of the vmspace?
Date: Mon, 21 Mar 2016 21:32:32 +0100

 An (untestested) simple/mechanical fix would be the change below.
 
 Chuck, care to review?
 
 Martin
 
 Index: uvm_mmap.c
 ===================================================================
 RCS file: /cvsroot/src/sys/uvm/uvm_mmap.c,v
 retrieving revision 1.154
 diff -u -p -r1.154 uvm_mmap.c
 --- uvm_mmap.c	26 Nov 2015 13:15:34 -0000	1.154
 +++ uvm_mmap.c	21 Mar 2016 20:27:12 -0000
 @@ -70,10 +70,10 @@ static int uvm_mmap(struct vm_map *, vad
  		    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;
  
 @@ -356,7 +356,7 @@ sys_mmap(struct lwp *l, const struct sys
  		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;
  		}
 @@ -487,16 +487,16 @@ sys___msync13(struct lwp *l, const struc
  	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?
  	 *
 @@ -573,12 +573,12 @@ sys_munmap(struct lwp *l, const struct s
  	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.
 @@ -634,7 +634,7 @@ sys_mprotect(struct lwp *l, const struct
  	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;
  
 @@ -675,7 +675,7 @@ sys_minherit(struct lwp *l, const struct
  	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;
  
 @@ -716,7 +716,7 @@ sys_madvise(struct lwp *l, const struct 
  	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;
  
 @@ -816,7 +816,7 @@ sys_mlock(struct lwp *l, const struct sy
  	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;
  
 @@ -867,7 +867,7 @@ sys_munlock(struct lwp *l, const struct 
  	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;
  
 


Home | Main Index | Thread Index | Old Index