Blame SOURCES/1297898-mpo-7.3.0-prctl.2.patch

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