Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Protect snapshots against write
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 14 Apr 2014 13:06:55 +0000 (15:06 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Mon, 14 Apr 2014 13:06:55 +0000 (15:06 +0200)
src/mc/mc_checkpoint.c

index d287c80..7864e2c 100644 (file)
@@ -89,6 +89,7 @@ static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size)
   new_reg->size = size;
   new_reg->data = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
   memcpy(new_reg->data, start_addr, size);
+  mprotect(new_reg->data, size, PROT_READ);
   madvise(new_reg->data, size, MADV_MERGEABLE);
 
   XBT_DEBUG("New region : type : %d, data : %p (real addr %p), size : %zu", type, new_reg->data, start_addr, size);