summaryrefslogtreecommitdiffstats
path: root/lib/libc/sys
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2017-07-30 10:36:20 +0000
committerkib <kib@FreeBSD.org>2017-07-30 10:36:20 +0000
commit3753ee3ec3e123ae4b62be3b19aaf09bf2e2ef59 (patch)
treeab6325da9a83553d80b966d8452d86913780f360 /lib/libc/sys
parentb556115e14ca8f088db11e894638cdd11ffc1f2e (diff)
downloadFreeBSD-src-3753ee3ec3e123ae4b62be3b19aaf09bf2e2ef59.zip
FreeBSD-src-3753ee3ec3e123ae4b62be3b19aaf09bf2e2ef59.tar.gz
Merge MAP_GUARD.
MFC r316687 (by markj), r320314, r320317, r320338, r320339, r320344, r320430, r320560 (by alc), r320801, r320843, r321173, r321230. Tested by: pho Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'lib/libc/sys')
-rw-r--r--lib/libc/sys/mmap.247
-rw-r--r--lib/libc/sys/munmap.24
2 files changed, 45 insertions, 6 deletions
diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2
index 7380a7f..1c9ff94 100644
--- a/lib/libc/sys/mmap.2
+++ b/lib/libc/sys/mmap.2
@@ -28,7 +28,7 @@
.\" @(#)mmap.2 8.4 (Berkeley) 5/11/95
.\" $FreeBSD$
.\"
-.Dd September 17, 2014
+.Dd June 22, 2017
.Dt MMAP 2
.Os
.Sh NAME
@@ -173,9 +173,21 @@ In contrast, if
.Dv MAP_EXCL
is specified, the request will fail if a mapping
already exists within the range.
-.It Dv MAP_HASSEMAPHORE
-Notify the kernel that the region may contain semaphores and that special
-handling may be necessary.
+.It Dv MAP_GUARD
+Instead of a mapping, create a guard of the specified size.
+Guards allow a process to create reservations in its address space,
+which can later be replaced by actual mappings.
+.Pp
+.Fa mmap
+will not create mappings in the address range of a guard unless
+the request specifies
+.Dv MAP_FIXED .
+Guards can be destroyed with
+.Xr munmap 2 .
+Any memory access by a thread to the guarded range results
+in the delivery of a
+.Dv SIGSEGV
+signal to that thread.
.It Dv MAP_NOCORE
Region is not included in a core file.
.It Dv MAP_NOSYNC
@@ -278,6 +290,7 @@ must include at least
.Dv PROT_READ
and
.Dv PROT_WRITE .
+.Pp
This option creates
a memory region that grows to at most
.Fa len
@@ -288,6 +301,12 @@ stack top is the starting address returned by the call, plus
bytes.
The bottom of the stack at maximum growth is the starting
address returned by the call.
+.Pp
+Stacks created with
+.Dv MAP_STACK
+automatically grow.
+Guards prevent inadvertent use of the regions into which those
+stacks can grow without requiring mapping the whole stack in advance.
.El
.Pp
The
@@ -375,6 +394,7 @@ were specified.
.It Bq Er EINVAL
None of
.Dv MAP_ANON ,
+.Dv MAP_GUARD ,
.Dv MAP_PRIVATE ,
.Dv MAP_SHARED ,
or
@@ -424,6 +444,25 @@ were specified, but the requested region is already used by a mapping.
was specified, but
.Dv MAP_FIXED
was not.
+.It Bq Er EINVAL
+.Dv MAP_GUARD
+was specified, but the
+.Fa offset
+argument was not zero, the
+.Fa fd
+argument was not -1, or the
+.Fa prot
+argument was not
+.Dv PROT_NONE .
+.It Bq Er EINVAL
+.Dv MAP_GUARD
+was specified together with one of the flags
+.Dv MAP_ANON ,
+.Dv MAP_PREFAULT ,
+.Dv MAP_PREFAULT_READ ,
+.Dv MAP_PRIVATE ,
+.Dv MAP_SHARED ,
+.Dv MAP_STACK .
.It Bq Er ENODEV
.Dv MAP_ANON
has not been specified and
diff --git a/lib/libc/sys/munmap.2 b/lib/libc/sys/munmap.2
index 6431072..ce54202 100644
--- a/lib/libc/sys/munmap.2
+++ b/lib/libc/sys/munmap.2
@@ -28,7 +28,7 @@
.\" @(#)munmap.2 8.3 (Berkeley) 5/27/94
.\" $FreeBSD$
.\"
-.Dd May 27, 1994
+.Dd June 22, 2017
.Dt MUNMAP 2
.Os
.Sh NAME
@@ -44,7 +44,7 @@
The
.Fn munmap
system call
-deletes the mappings for the specified address range,
+deletes the mappings and guards for the specified address range,
and causes further references to addresses within the range
to generate invalid memory references.
.Sh RETURN VALUES
OpenPOWER on IntegriCloud