aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Cooper <andrew.cooper3@citrix.com>2013-10-04 12:24:34 +0200
committerJan Beulich <jbeulich@suse.com>2013-10-04 12:24:34 +0200
commit7cfb0053629c4dd1a6f01dc43cca7c0c25b8b7bf (patch)
tree601e6c122d3e3f97c8da982a28db16f27e9bfba5
parent0aa27ce3351f7eb09d13e863a1d5f303086aa32a (diff)
downloadxen-7cfb0053629c4dd1a6f01dc43cca7c0c25b8b7bf.tar.gz
xen-7cfb0053629c4dd1a6f01dc43cca7c0c25b8b7bf.tar.bz2
xen-7cfb0053629c4dd1a6f01dc43cca7c0c25b8b7bf.zip
x86/percpu: Force INVALID_PERCPU_AREA into the non-canonical address region
This causes accidental uses of per_cpu() on a pcpu with an INVALID_PERCPU_AREA to result in a #GF for attempting to access the middle of the non-canonical virtual address region. This is preferable to the current behaviour, where incorrect use of per_cpu() will result in an effective NULL structure dereference which has security implication in the context of PV guests. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Keir Fraser <keir@xen.org>
-rw-r--r--xen/arch/x86/percpu.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/xen/arch/x86/percpu.c b/xen/arch/x86/percpu.c
index e5450248ad..1c1dad9011 100644
--- a/xen/arch/x86/percpu.c
+++ b/xen/arch/x86/percpu.c
@@ -6,7 +6,14 @@
#include <xen/rcupdate.h>
unsigned long __per_cpu_offset[NR_CPUS];
-#define INVALID_PERCPU_AREA (-(long)__per_cpu_start)
+
+/*
+ * Force uses of per_cpu() with an invalid area to attempt to access the
+ * middle of the non-canonical address space resulting in a #GP, rather than a
+ * possible #PF at (NULL + a little) which has security implications in the
+ * context of PV guests.
+ */
+#define INVALID_PERCPU_AREA (0x8000000000000000L - (long)__per_cpu_start)
#define PERCPU_ORDER (get_order_from_bytes(__per_cpu_data_end-__per_cpu_start))
void __init percpu_init_areas(void)