Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Do not attempt to make the heap writeable
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 28 Jul 2015 12:15:03 +0000 (14:15 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 28 Jul 2015 12:50:15 +0000 (14:50 +0200)
We add a mprotect()-based gap after the stacks (which are created on
the heap) in order to detect stack overflows but when the stack is
destroyed, the protection is removed by making the pages (part of the
heap) RW and executable. This is not a good idea :)

Apparently, it fails on Ubuntu because of PaX restrictions on
mprotect(): the mprotect calls fails, the pages are still unreadable
and unwritable and the application segfaults when a new allocation
attemps to use it.

src/simix/smx_context.c

index 5bcfdf9..d1e3594 100644 (file)
@@ -198,7 +198,7 @@ void SIMIX_context_stack_delete(void *stack)
   if (smx_context_guard_size > 0 && !MC_is_active()) {
     stack = (char *)stack - smx_context_guard_size;
     if (mprotect(stack, smx_context_guard_size,
-                 PROT_READ | PROT_WRITE | PROT_EXEC) == -1) {
+                 PROT_READ | PROT_WRITE) == -1) {
       XBT_WARN("Failed to remove page protection: %s", strerror(errno));
       /* try to pursue anyway */
     }