From 4031ad354b50c26fa507648a3e36ac145e6f256e Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Thu, 11 Apr 2013 00:33:12 +0100 Subject: [PATCH] Fixed JIT conflicts with SELinux (bug 5581, r=dvander). --- knight/shared/KeCodeAllocator.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/knight/shared/KeCodeAllocator.cpp b/knight/shared/KeCodeAllocator.cpp index c89aa126..976094fd 100644 --- a/knight/shared/KeCodeAllocator.cpp +++ b/knight/shared/KeCodeAllocator.cpp @@ -267,13 +267,8 @@ KeCodeRegion *ke_AddRegionForSize(KeCodeCache *cache, size_t size) #if defined KE_PLATFORM_WINDOWS region->block_start = (unsigned char *)VirtualAlloc(NULL, size, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE); #elif defined KE_PLATFORM_POSIX - region->block_start = (unsigned char *)valloc(size); - if (mprotect(region->block_start, size, PROT_READ|PROT_WRITE|PROT_EXEC) == -1) - { - free(region->block_start); - delete region; - return NULL; - } + region->block_start = (unsigned char *)mmap(NULL, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0); + region->block_start = (region->block_start == MAP_FAILED) ? NULL : region->block_start; #else #error "TODO" #endif @@ -389,7 +384,7 @@ KeCodeRegion *ke_DestroyRegion(KeCodeRegion *region) #if defined KE_PLATFORM_WINDOWS VirtualFree(region->block_start, 0, MEM_RELEASE); #else - free(region->block_start); + munmap(region->block_start, region->total_size); #endif delete region;