Blame rh1566890_speculative_store_bypass_so_added_more_per_task_speculation_control_CVE_2018_3639.patch

3e41b47
# ssbd2.patch
3e41b47
--- ./openjdk/hotspot/src/os/linux/vm/os_linux.cpp~	2018-05-02 13:02:51.924489199 -0400
3e41b47
+++ ./openjdk/hotspot/src/os/linux/vm/os_linux.cpp	2018-05-02 13:04:57.274216581 -0400
3e41b47
@@ -102,6 +102,8 @@
3e41b47
 # include <inttypes.h>
3e41b47
 # include <sys/ioctl.h>
3e41b47
 
3e41b47
+#include <sys/prctl.h>
3e41b47
+
3e41b47
 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
3e41b47
 
3e41b47
 #ifndef _GNU_SOURCE
3e41b47
@@ -4892,6 +4894,31 @@
3e41b47
   }
3e41b47
 }
3e41b47
 
3e41b47
+/* Per task speculation control */
3e41b47
+#ifndef PR_GET_SPECULATION_CTRL
3e41b47
+#define PR_GET_SPECULATION_CTRL    52
3e41b47
+#endif
3e41b47
+#ifndef PR_SET_SPECULATION_CTRL
3e41b47
+#define PR_SET_SPECULATION_CTRL    53
3e41b47
+#endif
3e41b47
+/* Speculation control variants */
3e41b47
+# undef PR_SPEC_STORE_BYPASS
3e41b47
+# define PR_SPEC_STORE_BYPASS          0
3e41b47
+/* Return and control values for PR_SET/GET_SPECULATION_CTRL */
3e41b47
+# undef PR_SPEC_NOT_AFFECTED
3e41b47
+# undef PR_SPEC_PRCTL
3e41b47
+# undef PR_SPEC_ENABLE
3e41b47
+# undef PR_SPEC_DISABLE
3e41b47
+# define PR_SPEC_NOT_AFFECTED          0
3e41b47
+# define PR_SPEC_PRCTL                 (1UL << 0)
3e41b47
+# define PR_SPEC_ENABLE                (1UL << 1)
3e41b47
+# define PR_SPEC_DISABLE               (1UL << 2)
3e41b47
+
3e41b47
+static void set_speculation() __attribute__((constructor));
3e41b47
+static void set_speculation() {
3e41b47
+  prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, 0, 0);
3e41b47
+}
3e41b47
+
3e41b47
 // this is called _before_ the most of global arguments have been parsed
3e41b47
 void os::init(void) {
3e41b47
   char dummy;   /* used to get a guess on initial stack address */