]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
xen/nospec: Introduce CONFIG_SPECULATIVE_HARDEN_ARRAY
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 31 Jan 2019 18:01:16 +0000 (18:01 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 4 Oct 2019 17:37:41 +0000 (18:37 +0100)
There are legitimate circumstance where array hardening is not wanted or
needed.  Allow it to be turned off.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/common/Kconfig
xen/include/xen/nospec.h

index e9247871a8ec38ea7d220e079a3a80860e07a005..7b5dd9d49596c333249ec36956386d37899188b9 100644 (file)
@@ -80,6 +80,30 @@ config HAS_CHECKPOLICY
        string
        option env="XEN_HAS_CHECKPOLICY"
 
+menu "Speculative hardening"
+
+config SPECULATIVE_HARDEN_ARRAY
+       bool "Speculative Array Hardening"
+       default y
+       ---help---
+         Contemporary processors may use speculative execution as a
+         performance optimisation, but this can potentially be abused by an
+         attacker to leak data via speculative sidechannels.
+
+         One source of data leakage is via speculative out-of-bounds array
+         accesses.
+
+         When enabled, specific array accesses which have been deemed liable
+         to be speculatively abused will be hardened to avoid out-of-bounds
+         accesses.
+
+         This is a best-effort mitigation.  There are no guarantees that all
+         areas of code open to abuse have been hardened.
+
+         If unsure, say Y.
+
+endmenu
+
 config KEXEC
        bool "kexec support"
        default y
index 2ac8feccc213da6beb56654ac63452b249e32c3e..76255bc46efe085d980aef625d27ca1814722f9b 100644 (file)
@@ -33,6 +33,7 @@ static inline unsigned long array_index_mask_nospec(unsigned long index,
 }
 #endif
 
+#ifdef CONFIG_SPECULATIVE_HARDEN_ARRAY
 /*
  * array_index_nospec - sanitize an array index after a bounds check
  *
@@ -58,6 +59,10 @@ static inline unsigned long array_index_mask_nospec(unsigned long index,
                                                                         \
     (typeof(_i)) (_i & _mask);                                          \
 })
+#else
+/* No index hardening. */
+#define array_index_nospec(index, size) ((void)(size), (index))
+#endif /* CONFIG_SPECULATIVE_HARDEN_ARRAY */
 
 /*
  * array_access_nospec - allow nospec access for static size arrays