[Mesa-dev] [PATCH] Disable the code that allocates W|X memory on OpenBSD
Jonathan Gray
jsg at jsg.id.au
Thu Sep 1 17:23:19 UTC 2016
OpenBSD now has strict W^X enforcement. Processes that violate
the policy get killed by the kernel. Don't attempt to use
executable memory on OpenBSD to avoid this.
Patch from Mark Kettenis.
Cc: 11.2 12.0 <mesa-stable at lists.freedesktop.org>
Signed-off-by: Mark Kettenis <kettenis at openbsd.org>
Signed-off-by: Jonathan Gray <jsg at jsg.id.au>
---
src/gallium/auxiliary/rtasm/rtasm_execmem.c | 12 ++++++++++++
src/mapi/u_execmem.c | 9 ++++++++-
src/mesa/main/execmem.c | 15 ++++++++++++++-
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/gallium/auxiliary/rtasm/rtasm_execmem.c b/src/gallium/auxiliary/rtasm/rtasm_execmem.c
index f7e605e..edbb459 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_execmem.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_execmem.c
@@ -69,6 +69,16 @@ static struct mem_block *exec_heap = NULL;
static unsigned char *exec_mem = NULL;
+#ifdef __OpenBSD__
+
+static int
+init_heap(void)
+{
+ return 0;
+}
+
+#else
+
static int
init_heap(void)
{
@@ -83,6 +93,8 @@ init_heap(void)
return (exec_mem != MAP_FAILED);
}
+#endif
+
void *
rtasm_exec_malloc(size_t size)
diff --git a/src/mapi/u_execmem.c b/src/mapi/u_execmem.c
index 89d5c1d..3af9d0a 100644
--- a/src/mapi/u_execmem.c
+++ b/src/mapi/u_execmem.c
@@ -45,8 +45,15 @@ static unsigned int head = 0;
static unsigned char *exec_mem = (unsigned char *)0;
+#if defined(__OpenBSD__)
-#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__)
+static int
+init_map(void)
+{
+ return 0;
+}
+
+#elif defined(__linux__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__)
#include <unistd.h>
#include <sys/mman.h>
diff --git a/src/mesa/main/execmem.c b/src/mesa/main/execmem.c
index 3a13385..87e4a38 100644
--- a/src/mesa/main/execmem.c
+++ b/src/mesa/main/execmem.c
@@ -36,7 +36,20 @@
-#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__)
+#if defined(__OpenBSD__)
+
+void *
+_mesa_exec_malloc(GLuint size)
+{
+ return NULL;
+}
+
+void
+_mesa_exec_free(void *addr)
+{
+}
+
+#elif defined(__linux__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__)
/*
* Allocate a large block of memory which can hold code then dole it out
--
2.9.3
More information about the mesa-dev
mailing list