summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Dempsky <matthew@cvs.openbsd.org>2014-06-27 23:21:48 +0000
committerMatthew Dempsky <matthew@cvs.openbsd.org>2014-06-27 23:21:48 +0000
commitb7f8055e34badcebfc1933b80f46410838b8fcf3 (patch)
treee1cb88b1dca1a8bc5fbaf25e405e6a275e352d01
parenta8a6c9752ffbf8768285109d0820b5f8b743fc59 (diff)
Fix mmap() flag usage: explicitly specify MAP_PRIVATE and drop useless
MAP_FILE and MAP_HASSEMAPHORE flags. Discussed with deraadt, tedu, and kettenis
-rw-r--r--lib/librthread/rthread_sem.c4
-rw-r--r--lib/librthread/rthread_stack.c5
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/librthread/rthread_sem.c b/lib/librthread/rthread_sem.c
index 1c367e34970..14252a83185 100644
--- a/lib/librthread/rthread_sem.c
+++ b/lib/librthread/rthread_sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_sem.c,v 1.18 2013/12/11 16:24:16 tedu Exp $ */
+/* $OpenBSD: rthread_sem.c,v 1.19 2014/06/27 23:21:47 matthew Exp $ */
/*
* Copyright (c) 2004,2005,2013 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -367,7 +367,7 @@ sem_open(const char *name, int oflag, ...)
created = 1;
}
sem = mmap(NULL, SEM_MMAP_SIZE, PROT_READ | PROT_WRITE,
- MAP_FILE | MAP_SHARED | MAP_HASSEMAPHORE, fd, 0);
+ MAP_SHARED, fd, 0);
close(fd);
if (sem == MAP_FAILED) {
errno = EINVAL;
diff --git a/lib/librthread/rthread_stack.c b/lib/librthread/rthread_stack.c
index 7b178a4fa78..f73178ff35f 100644
--- a/lib/librthread/rthread_stack.c
+++ b/lib/librthread/rthread_stack.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_stack.c,v 1.11 2013/12/18 16:42:08 deraadt Exp $ */
+/* $OpenBSD: rthread_stack.c,v 1.12 2014/06/27 23:21:47 matthew Exp $ */
/* $snafu: rthread_stack.c,v 1.12 2005/01/11 02:45:28 marc Exp $ */
/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
@@ -92,7 +92,8 @@ _rthread_alloc_stack(pthread_t thread)
size += guardsize;
/* actually allocate the real stack */
- base = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
+ base = mmap(NULL, size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANON, -1, 0);
if (base == MAP_FAILED) {
free(stack);
return (NULL);