|
|
7dd887 |
From 26057cba30205ed659094a2816557b439c651286 Mon Sep 17 00:00:00 2001
|
|
|
7dd887 |
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
|
|
|
7dd887 |
Date: Tue, 28 Jun 2016 13:28:29 +0200
|
|
|
7dd887 |
Subject: [PATCH 11/17] prctl.2: add description of Intel MPX calls
|
|
|
7dd887 |
|
|
|
7dd887 |
---
|
|
|
7dd887 |
man-pages/man2/prctl.2 | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
7dd887 |
1 file changed, 81 insertions(+)
|
|
|
7dd887 |
|
|
|
7dd887 |
diff --git a/man-pages/man2/prctl.2 b/man-pages/man2/prctl.2
|
|
|
7dd887 |
index 24e56d2..92eecf9 100644
|
|
|
7dd887 |
--- a/man-pages/man2/prctl.2
|
|
|
7dd887 |
+++ b/man-pages/man2/prctl.2
|
|
|
7dd887 |
@@ -47,6 +47,7 @@
|
|
|
7dd887 |
.\" PR_GET_TIMERSLACK
|
|
|
7dd887 |
.\" 2013-01-10 Kees Cook, document PR_SET_PTRACER
|
|
|
7dd887 |
.\" 2012-02-04 Michael kerrisk, document PR_{SET,GET}_CHILD_SUBREAPER
|
|
|
7dd887 |
+.\" 2014-11-10 Dave Hansen, document PR_MPX_{EN,DIS}ABLE_MANAGEMENT
|
|
|
7dd887 |
.\"
|
|
|
7dd887 |
.\"
|
|
|
7dd887 |
.TH PRCTL 2 2013-05-21 "Linux" "Linux Programmer's Manual"
|
|
|
7dd887 |
@@ -771,6 +772,77 @@ option.
|
|
|
7dd887 |
.\" symbolic-link transitions over all process running in a system.
|
|
|
7dd887 |
.\" ========== END FIXME
|
|
|
7dd887 |
.RE
|
|
|
7dd887 |
+.TP
|
|
|
7dd887 |
+.BR PR_MPX_ENABLE_MANAGEMENT ", " PR_MPX_DISABLE_MANAGEMENT " (since Linux 3.19) "
|
|
|
7dd887 |
+.\" commit fe3d197f84319d3bce379a9c0dc17b1f48ad358c
|
|
|
7dd887 |
+.\" See also http://lwn.net/Articles/582712/
|
|
|
7dd887 |
+.\" See also https://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler
|
|
|
7dd887 |
+Enable or disable kernel management of Memory Protection eXtensions (MPX)
|
|
|
7dd887 |
+bounds tables.
|
|
|
7dd887 |
+The
|
|
|
7dd887 |
+.IR arg2 ,
|
|
|
7dd887 |
+.IR arg3 ,
|
|
|
7dd887 |
+.IR arg4 ,
|
|
|
7dd887 |
+and
|
|
|
7dd887 |
+.IR arg5
|
|
|
7dd887 |
+.\" commit e9d1b4f3c60997fe197bf0243cb4a41a44387a88
|
|
|
7dd887 |
+arguments must be zero.
|
|
|
7dd887 |
+
|
|
|
7dd887 |
+MPX is a hardware-assisted mechanism for performing bounds checking on
|
|
|
7dd887 |
+pointers.
|
|
|
7dd887 |
+It consists of a set of registers storing bounds information
|
|
|
7dd887 |
+and a set of special instruction prefixes that tell the CPU on which
|
|
|
7dd887 |
+instructions it should do bounds enforcement.
|
|
|
7dd887 |
+There is a limited number of these registers and
|
|
|
7dd887 |
+when there are more pointers than registers,
|
|
|
7dd887 |
+their contents must be "spilled" into a set of tables.
|
|
|
7dd887 |
+These tables are called "bounds tables" and the MPX
|
|
|
7dd887 |
+.BR prctl ()
|
|
|
7dd887 |
+operations control
|
|
|
7dd887 |
+whether the kernel manages their allocation and freeing.
|
|
|
7dd887 |
+
|
|
|
7dd887 |
+When management is enabled, the kernel will take over allocation
|
|
|
7dd887 |
+and freeing of the bounds tables.
|
|
|
7dd887 |
+It does this by trapping the #BR exceptions that result
|
|
|
7dd887 |
+at first use of missing bounds tables and
|
|
|
7dd887 |
+instead of delivering the exception to user space,
|
|
|
7dd887 |
+it allocates the table and populates the bounds directory
|
|
|
7dd887 |
+with the location of the new table.
|
|
|
7dd887 |
+For freeing, the kernel checks to see if bounds tables are
|
|
|
7dd887 |
+present for memory which is not allocated, and frees them if so.
|
|
|
7dd887 |
+
|
|
|
7dd887 |
+Before enabling MPX management using
|
|
|
7dd887 |
+.BR PR_MPX_ENABLE_MANAGEMENT ,
|
|
|
7dd887 |
+the application must first have allocated a user-space buffer for
|
|
|
7dd887 |
+the bounds directory and placed the location of that directory in the
|
|
|
7dd887 |
+.I bndcfgu
|
|
|
7dd887 |
+register.
|
|
|
7dd887 |
+
|
|
|
7dd887 |
+These calls will fail if the CPU or kernel does not support MPX.
|
|
|
7dd887 |
+Kernel support for MPX is enabled via the
|
|
|
7dd887 |
+.BR CONFIG_X86_INTEL_MPX
|
|
|
7dd887 |
+configuration option.
|
|
|
7dd887 |
+You can check whether the CPU supports MPX by looking for the 'mpx'
|
|
|
7dd887 |
+CPUID bit, like with the following command:
|
|
|
7dd887 |
+
|
|
|
7dd887 |
+ cat /proc/cpuinfo | grep ' mpx '
|
|
|
7dd887 |
+
|
|
|
7dd887 |
+A thread may not switch in or out of long (64-bit) mode while MPX is
|
|
|
7dd887 |
+enabled.
|
|
|
7dd887 |
+
|
|
|
7dd887 |
+All threads in a process are affected by these calls.
|
|
|
7dd887 |
+
|
|
|
7dd887 |
+The child of a
|
|
|
7dd887 |
+.BR fork (2)
|
|
|
7dd887 |
+inherits the state of MPX management.
|
|
|
7dd887 |
+During
|
|
|
7dd887 |
+.BR execve (2),
|
|
|
7dd887 |
+MPX management is reset to a state as if
|
|
|
7dd887 |
+.BR PR_MPX_DISABLE_MANAGEMENT
|
|
|
7dd887 |
+had been called.
|
|
|
7dd887 |
+
|
|
|
7dd887 |
+For further information on Intel MPX, see the kernel source file
|
|
|
7dd887 |
+.IR Documentation/x86/intel_mpx.txt .
|
|
|
7dd887 |
.\"
|
|
|
7dd887 |
.SH RETURN VALUE
|
|
|
7dd887 |
On success,
|
|
|
7dd887 |
@@ -957,6 +1029,15 @@ capability.
|
|
|
7dd887 |
.\" is
|
|
|
7dd887 |
.\" .BR PR_SET_SECCOMP ,
|
|
|
7dd887 |
.\" and secure computing mode is already 1.
|
|
|
7dd887 |
+.TP
|
|
|
7dd887 |
+.B ENXIO
|
|
|
7dd887 |
+.I option
|
|
|
7dd887 |
+was
|
|
|
7dd887 |
+.BR PR_MPX_ENABLE_MANAGEMENT
|
|
|
7dd887 |
+or
|
|
|
7dd887 |
+.BR PR_MPX_DISABLE_MANAGEMENT
|
|
|
7dd887 |
+and the kernel or the CPU does not support MPX management.
|
|
|
7dd887 |
+Check that the kernel and processor have MPX support.
|
|
|
7dd887 |
.SH VERSIONS
|
|
|
7dd887 |
The
|
|
|
7dd887 |
.BR prctl ()
|
|
|
7dd887 |
--
|
|
|
7dd887 |
2.7.4
|
|
|
7dd887 |
|