From eeb1ebf124d9c1b108ce628aa98d1af7875d3334 Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 25 Mar 2011 16:38:10 +0000 Subject: [PATCH] Handle the corner case in vm_fault_quick_hold_pages(). If supplied length is zero, and user address is invalid, function might return -1, due to the truncation and rounding of the address. The callers interpret the situation as EFAULT. Instead of handling the zero length in caller, filter it in vm_fault_quick_hold_pages(). Sponsored by: The FreeBSD Foundation Reviewed by: alc --- sys/vm/vm_fault.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index 43da60209846..d417a8450833 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -1058,6 +1058,8 @@ vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len, int count; boolean_t pmap_failed; + if (len == 0) + return (0); end = round_page(addr + len); addr = trunc_page(addr);