aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-04-15 16:31:34 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-04-17 13:47:59 +0200
commit25c332c00e636403b7600e3ac7110cde8d0fab7f (patch)
tree6092e72a0de084c93e57c99809b600936b38f73e
parentc74a173b2a070b1be7cfaac79c5ed6aaf3431ebb (diff)
iOS: Don't enable PROT_WRITE and PROT_EXEC at the same time
We define ENABLE_ASSEMBLER_WX_EXCLUSIVE, which we use to limit the page flags to either RW or RX. Change-Id: I253648ea98610438a533c7a7ccbf5c27c3b8230a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/3rdparty/masm/stubs/ExecutableAllocator.h17
-rw-r--r--src/qml/qml/v4vm/v4vm.pri2
2 files changed, 17 insertions, 2 deletions
diff --git a/src/3rdparty/masm/stubs/ExecutableAllocator.h b/src/3rdparty/masm/stubs/ExecutableAllocator.h
index 6ebea24a15..a6911b34f0 100644
--- a/src/3rdparty/masm/stubs/ExecutableAllocator.h
+++ b/src/3rdparty/masm/stubs/ExecutableAllocator.h
@@ -94,8 +94,18 @@ struct ExecutableAllocator {
return adoptRef(new ExecutableMemoryHandle(realAllocator, size));
}
- static void makeWritable(void*, int)
+ static void makeWritable(void* addr, int size)
{
+#if ENABLE(ASSEMBLER_WX_EXCLUSIVE)
+ size_t pageSize = WTF::pageSize();
+ size_t iaddr = reinterpret_cast<size_t>(addr);
+ size_t roundAddr = iaddr & ~(pageSize - static_cast<size_t>(1));
+
+ int mode = PROT_READ | PROT_WRITE;
+ mprotect(reinterpret_cast<void*>(roundAddr), size + (iaddr - roundAddr), mode);
+#else
+ // We assume we already have RWX
+#endif
}
static void makeExecutable(void* addr, int size)
@@ -107,7 +117,10 @@ struct ExecutableAllocator {
DWORD oldProtect;
VirtualProtect(reinterpret_cast<void*>(roundAddr), size + (iaddr - roundAddr), PAGE_EXECUTE_READWRITE, &oldProtect);
#else
- int mode = PROT_READ | PROT_WRITE | PROT_EXEC;
+ int mode = PROT_READ | PROT_EXEC;
+#if !ENABLE(ASSEMBLER_WX_EXCLUSIVE)
+ mode |= PROT_WRITE;
+#endif
mprotect(reinterpret_cast<void*>(roundAddr), size + (iaddr - roundAddr), mode);
#endif
}
diff --git a/src/qml/qml/v4vm/v4vm.pri b/src/qml/qml/v4vm/v4vm.pri
index d406b55fe2..92f13ab92f 100644
--- a/src/qml/qml/v4vm/v4vm.pri
+++ b/src/qml/qml/v4vm/v4vm.pri
@@ -154,6 +154,8 @@ valgrind {
DEFINES += V4_USE_VALGRIND
}
+ios: DEFINES += ENABLE_ASSEMBLER_WX_EXCLUSIVE=1
+
include(moth/moth.pri)
include(../../../3rdparty/masm/masm.pri)
include(../../../3rdparty/double-conversion/double-conversion.pri)