aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kerrisk <mtk.manpages@gmail.com>2016-10-13 12:44:52 +0200
committerMichael Kerrisk <mtk.manpages@gmail.com>2016-10-17 14:04:17 +0200
commit9e7d6be1f5d3b4a97f1e9f892e8180b82f6e2ccd (patch)
tree9881a87cbe8504bb027c7ea660410934543d2453
parentf74aed0e620fd948756e856efe6d6f4c908e844c (diff)
downloadman-pages-9e7d6be1f5d3b4a97f1e9f892e8180b82f6e2ccd.tar.gz
mprotect.2: Various tweaks to the text
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
-rw-r--r--man2/mprotect.235
1 files changed, 25 insertions, 10 deletions
diff --git a/man2/mprotect.2 b/man2/mprotect.2
index 9cc3753643..05efc27285 100644
--- a/man2/mprotect.2
+++ b/man2/mprotect.2
@@ -48,9 +48,7 @@ mprotect, pkey_mprotect \- set protection on a region of memory
.fi
.SH DESCRIPTION
.BR mprotect ()
-and
-.BR pkey_mprotect ()
-change protection for the calling process's memory page(s)
+changes protection for the calling process's memory page(s)
containing any part of the address range in the
interval [\fIaddr\fP,\ \fIaddr\fP+\fIlen\fP\-1].
.I addr
@@ -78,19 +76,31 @@ The memory can be modified.
.B PROT_EXEC
The memory can be executed.
.PP
+Like
+.BR mprotect (),
+.BR pkey_mprotect ()
+changes the protection on the pages specified by
+.IR addr
+and
+.IR len .
+The
.I pkey
-is the protection key to assign to the memory.
-A pkey must be allocated with
+argument specifies the protection key (see
+.BR pkey (7))
+to assign to the memory.
+The protection key must be allocated with
.BR pkey_alloc (2)
before it is passed to
.BR pkey_mprotect ().
+For an example of the use of this system call, see
+.BR pkey (7).
.SH RETURN VALUE
On success,
.BR mprotect ()
and
.BR pkey_mprotect ()
return zero.
-On error, \-1 is returned, and
+On error, these system calls return \-1, and
.I errno
is set appropriately.
.SH ERRORS
@@ -107,7 +117,10 @@ to mark it
.B EINVAL
\fIaddr\fP is not a valid pointer,
or not a multiple of the system page size.
-Or: \fIpkey\fP has not been allocated with
+.TP
+.BR EINVAL
+.RB ( pkey_mprotect ())
+\fIpkey\fP has not been allocated with
.BR pkey_alloc (2)
.\" Or: both PROT_GROWSUP and PROT_GROWSDOWN were specified in 'prot'.
.TP
@@ -191,7 +204,7 @@ has been set.
Applications should be careful when mixing use of
.BR mprotect ()
and
-.BR pkey_mprotect () .
+.BR pkey_mprotect ().
On x86, when
.BR mprotect ()
is used with
@@ -213,7 +226,9 @@ is equivalent to
.SH EXAMPLE
.\" sigaction.2 refers to this example
.PP
-The program below allocates four pages of memory, makes the third
+The program below demonstrates the use of
+.BR mprotect ()
+The program allocates four pages of memory, makes the third
of these pages read-only, and then executes a loop that walks upward
through the allocated region modifying bytes.
@@ -290,5 +305,5 @@ main(int argc, char *argv[])
.fi
.SH SEE ALSO
.BR mmap (2),
-.BR sysconf (3)
+.BR sysconf (3),
.BR pkey (7)