summaryrefslogtreecommitdiff
path: root/sys/uvm
diff options
context:
space:
mode:
authorMatthew Dempsky <matthew@cvs.openbsd.org>2012-07-21 06:46:59 +0000
committerMatthew Dempsky <matthew@cvs.openbsd.org>2012-07-21 06:46:59 +0000
commit3b601b6ca59a3be32c026b629686e87a8e614ea9 (patch)
treeb62860e1a6befb811e2f0713e1ab24914d2247c5 /sys/uvm
parent859a2a5c1795bb2e5d470325503b9324c5e9ef36 (diff)
Add a new mmap(2) flag __MAP_NOREMAP for use with MAP_FIXED to
indicate that the kernel should fail with MAP_FAILED if the specified address is not currently available instead of unmapping it. Change ld.so on i386 to make use of __MAP_NOREMAP to improve reliability. __MAP_NOREMAP diff by guenther based on an earlier diff by Ariane; ld.so bits by guenther and me bulk build stress testing of earlier diffs by sthen ok deraadt; committing now for further testing
Diffstat (limited to 'sys/uvm')
-rw-r--r--sys/uvm/uvm_mmap.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c
index da9a291c877..25c1306b87e 100644
--- a/sys/uvm/uvm_mmap.c
+++ b/sys/uvm/uvm_mmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_mmap.c,v 1.90 2012/04/22 05:43:14 guenther Exp $ */
+/* $OpenBSD: uvm_mmap.c,v 1.91 2012/07/21 06:46:58 matthew Exp $ */
/* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */
/*
@@ -362,6 +362,8 @@ sys_mmap(struct proc *p, void *v, register_t *retval)
flags = (flags & ~MAP_COPY) | MAP_PRIVATE;
if ((flags & (MAP_SHARED|MAP_PRIVATE)) == (MAP_SHARED|MAP_PRIVATE))
return (EINVAL);
+ if ((flags & (MAP_FIXED|__MAP_NOREPLACE)) == __MAP_NOREPLACE)
+ return (EINVAL);
if (size == 0)
return (EINVAL);
@@ -994,8 +996,10 @@ uvm_mmap(vm_map_t map, vaddr_t *addr, vsize_t size, vm_prot_t prot,
} else {
if (*addr & PAGE_MASK)
return(EINVAL);
+
uvmflag |= UVM_FLAG_FIXED;
- uvm_unmap(map, *addr, *addr + size); /* zap! */
+ if ((flags & __MAP_NOREPLACE) == 0)
+ uvm_unmap(map, *addr, *addr + size); /* zap! */
}
/*