Re: [GIT pull] x86 mpx support for 3.19

From: Dave Hansen
Date: Wed Dec 10 2014 - 15:39:48 EST


On 12/10/2014 11:49 AM, Linus Torvalds wrote:
> On Wed, Dec 10, 2014 at 11:41 AM, Dave Hansen
> <dave.hansen@xxxxxxxxxxxxxxx> wrote:
>> But, this is the kind of option that we want to be *sure* is enabled
>> unless folks know exactly what they are doing, so we should probably
>> hide it behind CONFIG_EXPERT as well, just as SMEP is.
>
> I disagree.
>
> SMEP doesn't have any performance overhead, and SMEP is available in
> processors available today. So SMEP doesn't even have a config option,
> because there is no downside with having it on and enabled.

I misspoke there. I meant SMAP (I placed MPX below its config option).

> MPX, in contrast, you don't even normally want to run at all as a
> normal user because of the overheads. That's going to be true even
> when it's available.

The overhead of turning the MPX config option on really is tiny. We
have a few code touch points like around munmap(), but it should not be
noticeable.

One thing we are *not* doing under this config option is actually
instrumenting kernel code or doing any protection of the kernel itself.
This is only about supporting user applications that are doing MPX.
This set contains no support for doing MPX _inside_ the kernel.

We probably need to mention this explicitly in the config option. I've
added:

> This option enables running applications which are
> instrumented or otherwise use MPX. It does not use MPX
> itself inside the kernel or to protect the kernel
> against bad memory references.


From: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>

Give MPX a real config option. The CPUs that support it
(referenced here):

https://software.intel.com/en-us/forums/topic/402393

are not available publicly, so we need to make it somewhat
easy to disable.

Signed-off-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
---

b/arch/x86/Kconfig | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)

diff -puN arch/x86/Kconfig~x86-mpx-real-config-option arch/x86/Kconfig
--- a/arch/x86/Kconfig~x86-mpx-real-config-option 2014-12-10 11:19:13.638835732 -0800
+++ b/arch/x86/Kconfig 2014-12-10 12:30:53.762779608 -0800
@@ -248,10 +248,6 @@ config HAVE_INTEL_TXT
def_bool y
depends on INTEL_IOMMU && ACPI

-config X86_INTEL_MPX
- def_bool y
- depends on CPU_SUP_INTEL
-
config X86_32_SMP
def_bool y
depends on X86_32 && SMP
@@ -1575,6 +1571,27 @@ config X86_SMAP

If unsure, say Y.

+config X86_INTEL_MPX
+ prompt "Intel MPX (Memory Protection Extensions)" if EXPERT
+ def_bool y
+ depends on CPU_SUP_INTEL
+ ---help---
+ MPX provides hardware features that can be used in
+ conjunction with compiler-instrumented code to check
+ memory references. It is designed to detect buffer
+ overflow or underflow bugs.
+
+ This option enables running applications which are
+ instrumented or otherwise use MPX. It does not use MPX
+ itself inside the kernel or to protect the kernel
+ against bad memory references.
+
+ Enabling this option will make the kernel larger and
+ slightly increase the size of some kernel data
+ structures.
+
+ If unsure, say Y.
+
config EFI
bool "EFI runtime service support"
depends on ACPI
_