pkey_alloc.2: Reorganize text

No content changes.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2016-10-13 12:32:19 +02:00
parent b638d22097
commit e956ced871
1 changed files with 33 additions and 32 deletions

View File

@ -37,38 +37,6 @@ pkey_alloc, pkey_free \- allocate or free a protection key
allocates a protection key (pkey) and allows it to be passed to
.BR pkey_mprotect (2).
.BR pkey_alloc ()
is always safe to call regardless of whether or not the operating system
supports protection keys.
It can be used in lieu of any other mechanism for detecting pkey support
and will simply fail with the error
.B ENOSPC
if the operating system has no pkey support.
The kernel guarantees that the contents of the hardware rights
register (PKRU) will be preserved only for allocated protection
keys.
Any time a key is unallocated (either before the first call
returning that key from
.BR pkey_alloc ()
or after it is freed via
.BR pkey_free ()),
the kernel may make arbitrary changes to the parts of the
rights register affecting access to that key.
.PP
.BR pkey_free ()
frees a protection key and makes it available for later
allocations.
After a protection key has been freed, it may no longer be used
in any protection-key-related operations.
An application should not call
.BR pkey_free ()
on any protection key which has been assigned to an address
range by
.BR pkey_mprotect (2)
and which is still in use.
The behavior in this case is undefined and may result in an error.
.PP
The
.BR pkey_alloc ()
.I flags
@ -79,6 +47,20 @@ Disable all data access to memory covered by the returned protection key.
.TP
.B PKEY_DISABLE_WRITE
Disable write access to memory covered by the returned protection key.
.PP
.BR pkey_free ()
frees a protection key and makes it available for later
allocations.
After a protection key has been freed, it may no longer be used
in any protection-key-related operations.
An application should not call
.BR pkey_free ()
on any protection key which has been assigned to an address
range by
.BR pkey_mprotect (2)
and which is still in use.
The behavior in this case is undefined and may result in an error.
.SH RETURN VALUE
On success,
.BR pkey_alloc ()
@ -123,6 +105,25 @@ The
and
.BR pkey_free ()
system calls are Linux-specific.
.SH NOTES
.BR pkey_alloc ()
is always safe to call regardless of whether or not the operating system
supports protection keys.
It can be used in lieu of any other mechanism for detecting pkey support
and will simply fail with the error
.B ENOSPC
if the operating system has no pkey support.
The kernel guarantees that the contents of the hardware rights
register (PKRU) will be preserved only for allocated protection
keys.
Any time a key is unallocated (either before the first call
returning that key from
.BR pkey_alloc ()
or after it is freed via
.BR pkey_free ()),
the kernel may make arbitrary changes to the parts of the
rights register affecting access to that key.
.SH SEE ALSO
.BR pkey_mprotect (2),
.BR pkey (7)