From: Tom Hughes Date: Wed, 2 Nov 2005 13:02:40 +0000 (+0000) Subject: Don't give the heap execute permission - the linux kernel doesn't X-Git-Tag: svn/VALGRIND_3_1_0~249 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dbfe36c3c347f6092a65ed2b1330156cafbf8855;p=thirdparty%2Fvalgrind.git Don't give the heap execute permission - the linux kernel doesn't normally give execute permission to memory allocated from the heap with sbrk. This also required fixing the smc1 test for amd64 to use mmap to allocate memory so that it can have execute permission. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4983 --- diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 87cefab9cc..2d57828a72 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -669,7 +669,7 @@ static void setup_client_dataseg ( SizeT max_size ) sres = VG_(am_mmap_anon_fixed_client)( anon_start, anon_size, - VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC + VKI_PROT_READ|VKI_PROT_WRITE ); vg_assert(!sres.isError); vg_assert(sres.val == anon_start); diff --git a/none/tests/amd64/smc1.c b/none/tests/amd64/smc1.c index 1fc91ee51d..8619c1efda 100644 --- a/none/tests/amd64/smc1.c +++ b/none/tests/amd64/smc1.c @@ -31,7 +31,7 @@ #include #include -#include +#include typedef unsigned long long int Addr; typedef unsigned char UChar; @@ -100,8 +100,9 @@ void diversion ( void ) { } int main ( void ) { int i; - code = malloc(20); - assert(code); + code = mmap(NULL, 20, PROT_READ|PROT_WRITE|PROT_EXEC, + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + assert(code != MAP_FAILED); for (i = 0; i < 10; i += 2) { set_dest ( (Addr)&p ); // diversion(); @@ -110,5 +111,6 @@ int main ( void ) // diversion(); aa(i+1); } + munmap(code, 20); return 0; }