diff options
author | kib <kib@FreeBSD.org> | 2014-06-26 08:30:08 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2014-06-26 08:30:08 +0000 |
commit | 15d33955d24d5a4bf051e41cff28951c6c2a54f2 (patch) | |
tree | 2c593f33e1723fee9862fe84487989f08054fd73 /sys/vm | |
parent | b371ec04aaeccdccafd21a04b949901c090e50cb (diff) | |
download | FreeBSD-src-15d33955d24d5a4bf051e41cff28951c6c2a54f2.zip FreeBSD-src-15d33955d24d5a4bf051e41cff28951c6c2a54f2.tar.gz |
MFC r267630:
Add MAP_EXCL flag for mmap(2).
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_map.c | 3 | ||||
-rw-r--r-- | sys/vm/vm_map.h | 1 | ||||
-rw-r--r-- | sys/vm/vm_mmap.c | 4 |
3 files changed, 7 insertions, 1 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 1cc125b..62785f1 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -1407,7 +1407,8 @@ vm_map_fixed(vm_map_t map, vm_object_t object, vm_ooffset_t offset, ("vm_map_fixed: non-NULL backing object for stack")); vm_map_lock(map); VM_MAP_RANGE_CHECK(map, start, end); - (void) vm_map_delete(map, start, end); + if ((cow & MAP_CHECK_EXCL) == 0) + vm_map_delete(map, start, end); if ((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) != 0) { result = vm_map_stack_locked(map, start, length, sgrowsiz, prot, max, cow); diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index 850bf25..8cced05 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -315,6 +315,7 @@ long vmspace_resident_count(struct vmspace *vmspace); #define MAP_PREFAULT 0x0008 #define MAP_PREFAULT_PARTIAL 0x0010 #define MAP_DISABLE_SYNCER 0x0020 +#define MAP_CHECK_EXCL 0x0040 #define MAP_DISABLE_COREDUMP 0x0100 #define MAP_PREFAULT_MADVISE 0x0200 /* from (user) madvise request */ #define MAP_VN_WRITECOUNT 0x0400 diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 6edf560..72dea74 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -245,6 +245,8 @@ sys_mmap(td, uap) flags |= MAP_ANON; pos = 0; } + if ((flags & (MAP_EXCL | MAP_FIXED)) == MAP_EXCL) + return (EINVAL); /* * Align the file position to a page boundary, @@ -1626,6 +1628,8 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, return (EINVAL); docow |= MAP_STACK_GROWS_DOWN; } + if ((flags & MAP_EXCL) != 0) + docow |= MAP_CHECK_EXCL; if (fitit) { if ((flags & MAP_ALIGNMENT_MASK) == MAP_ALIGNED_SUPER) |