|
From: <sv...@va...> - 2005-11-02 13:02:42
|
Author: tom
Date: 2005-11-02 13:02:40 +0000 (Wed, 02 Nov 2005)
New Revision: 4983
Log:
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.
Modified:
trunk/coregrind/m_main.c
trunk/none/tests/amd64/smc1.c
Modified: trunk/coregrind/m_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_main.c 2005-11-02 13:00:41 UTC (rev 4982)
+++ trunk/coregrind/m_main.c 2005-11-02 13:02:40 UTC (rev 4983)
@@ -669,7 +669,7 @@
sres =3D VG_(am_mmap_anon_fixed_client)(=20
anon_start,=20
anon_size,=20
- VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC=20
+ VKI_PROT_READ|VKI_PROT_WRITE
);
vg_assert(!sres.isError);
vg_assert(sres.val =3D=3D anon_start);
Modified: trunk/none/tests/amd64/smc1.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/none/tests/amd64/smc1.c 2005-11-02 13:00:41 UTC (rev 4982)
+++ trunk/none/tests/amd64/smc1.c 2005-11-02 13:02:40 UTC (rev 4983)
@@ -31,7 +31,7 @@
=20
#include <stdio.h>
#include <assert.h>
-#include <malloc.h>
+#include <sys/mman.h>
=20
typedef unsigned long long int Addr;
typedef unsigned char UChar;
@@ -100,8 +100,9 @@
int main ( void )
{
int i;
- code =3D malloc(20);
- assert(code);
+ code =3D mmap(NULL, 20, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ assert(code !=3D MAP_FAILED);
for (i =3D 0; i < 10; i +=3D 2) {
set_dest ( (Addr)&p );
// diversion();
@@ -110,5 +111,6 @@
// diversion();
aa(i+1);
}
+ munmap(code, 20);
return 0;
}
|