Permalink
Browse files

Update cmm_init to use PROT_NONE

  • Loading branch information...
hausdorff committed Apr 13, 2014
1 parent 5accdd5 commit ba8c04147b007b55d9ecab50eb3e2061326fa4fe
Showing with 6 additions and 2 deletions.
  1. +5 −1 crypto/buddy_allocator.c
  2. +1 −1 crypto/buildinf.h
View
@@ -40,6 +40,8 @@ void *
cmm_init(int size, int mem_min_unit, int overrun_bytes)
{
int i;
+ size_t pgsize = (size_t)sysconf(_SC_PAGE_SIZE);
+ size_t aligned = (pgsize + size + (pgsize - 1)) & ~(pgsize - 1);
mem_arena_size = size;
Mem_min_unit = mem_min_unit,
@@ -71,9 +73,11 @@ cmm_init(int size, int mem_min_unit, int overrun_bytes)
assert(cmm_bitmalloc);
memset(cmm_bitmalloc, 0, cmm_bittable_size>>3);
- cmm_arena = mmap(NULL, mem_arena_size, PROT_READ|PROT_WRITE,
+ cmm_arena = mmap(NULL, pgsize + mem_arena_size + pgsize, PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, 0, 0);
assert(MAP_FAILED != cmm_arena);
+ mprotect(cmm_arena, pgsize, PROT_NONE);
+ mprotect(cmm_arena + aligned, pgsize, PROT_NONE);
set_bit(cmm_arena, 0, cmm_bittable);
cmm_add_to_list(&cmm_free_list[0], cmm_arena);
View
@@ -2,5 +2,5 @@
/* auto-generated by crypto/Makefile for crypto/cversion.c */
#define CFLAGS "gcc -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM"
#define PLATFORM "linux-x86_64"
- #define DATE "Sat Apr 12 14:47:28 PDT 2014"
+ #define DATE "Sun Apr 13 00:12:27 PDT 2014"
#endif

0 comments on commit ba8c041

Please sign in to comment.