mprotect.2: Various tweaks to the text

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2016-10-13 12:44:52 +02:00
parent f74aed0e62
commit 9e7d6be1f5
1 changed files with 25 additions and 10 deletions

View File

@ -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)