Commit 5a8b7dc6 authored by Shenghou Ma's avatar Shenghou Ma

runtime: remove PROT_EXEC from mmap calls.

Executable heap is gone on Unix!

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/7405045
parent 89ec3a61
...@@ -14,7 +14,7 @@ runtime·SysAlloc(uintptr n) ...@@ -14,7 +14,7 @@ runtime·SysAlloc(uintptr n)
void *v; void *v;
mstats.sys += n; mstats.sys += n;
v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0); v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(v < (void*)4096) if(v < (void*)4096)
return nil; return nil;
return v; return v;
...@@ -51,7 +51,7 @@ runtime·SysMap(void *v, uintptr n) ...@@ -51,7 +51,7 @@ runtime·SysMap(void *v, uintptr n)
void *p; void *p;
mstats.sys += n; mstats.sys += n;
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0); p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
if(p == (void*)-ENOMEM) if(p == (void*)-ENOMEM)
runtime·throw("runtime: out of memory"); runtime·throw("runtime: out of memory");
if(p != v) if(p != v)
......
...@@ -14,7 +14,7 @@ runtime·SysAlloc(uintptr n) ...@@ -14,7 +14,7 @@ runtime·SysAlloc(uintptr n)
void *v; void *v;
mstats.sys += n; mstats.sys += n;
v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0); v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(v < (void*)4096) if(v < (void*)4096)
return nil; return nil;
return v; return v;
...@@ -59,7 +59,7 @@ runtime·SysMap(void *v, uintptr n) ...@@ -59,7 +59,7 @@ runtime·SysMap(void *v, uintptr n)
// On 64-bit, we don't actually have v reserved, so tread carefully. // On 64-bit, we don't actually have v reserved, so tread carefully.
if(sizeof(void*) == 8) { if(sizeof(void*) == 8) {
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0); p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(p == (void*)-ENOMEM) if(p == (void*)-ENOMEM)
runtime·throw("runtime: out of memory"); runtime·throw("runtime: out of memory");
if(p != v) { if(p != v) {
...@@ -69,7 +69,7 @@ runtime·SysMap(void *v, uintptr n) ...@@ -69,7 +69,7 @@ runtime·SysMap(void *v, uintptr n)
return; return;
} }
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0); p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
if(p == (void*)-ENOMEM) if(p == (void*)-ENOMEM)
runtime·throw("runtime: out of memory"); runtime·throw("runtime: out of memory");
if(p != v) if(p != v)
......
...@@ -57,7 +57,7 @@ runtime·SysAlloc(uintptr n) ...@@ -57,7 +57,7 @@ runtime·SysAlloc(uintptr n)
void *p; void *p;
mstats.sys += n; mstats.sys += n;
p = runtime·mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0); p = runtime·mmap(nil, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(p < (void*)4096) { if(p < (void*)4096) {
if(p == (void*)EACCES) { if(p == (void*)EACCES) {
runtime·printf("runtime: mmap: access denied\n"); runtime·printf("runtime: mmap: access denied\n");
...@@ -118,7 +118,7 @@ runtime·SysMap(void *v, uintptr n) ...@@ -118,7 +118,7 @@ runtime·SysMap(void *v, uintptr n)
// On 64-bit, we don't actually have v reserved, so tread carefully. // On 64-bit, we don't actually have v reserved, so tread carefully.
if(sizeof(void*) == 8 && (uintptr)v >= 0xffffffffU) { if(sizeof(void*) == 8 && (uintptr)v >= 0xffffffffU) {
p = mmap_fixed(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0); p = mmap_fixed(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(p == (void*)ENOMEM) if(p == (void*)ENOMEM)
runtime·throw("runtime: out of memory"); runtime·throw("runtime: out of memory");
if(p != v) { if(p != v) {
...@@ -128,7 +128,7 @@ runtime·SysMap(void *v, uintptr n) ...@@ -128,7 +128,7 @@ runtime·SysMap(void *v, uintptr n)
return; return;
} }
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0); p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
if(p == (void*)ENOMEM) if(p == (void*)ENOMEM)
runtime·throw("runtime: out of memory"); runtime·throw("runtime: out of memory");
if(p != v) if(p != v)
......
...@@ -19,7 +19,7 @@ runtime·SysAlloc(uintptr n) ...@@ -19,7 +19,7 @@ runtime·SysAlloc(uintptr n)
void *v; void *v;
mstats.sys += n; mstats.sys += n;
v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0); v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(v < (void*)4096) if(v < (void*)4096)
return nil; return nil;
return v; return v;
...@@ -65,7 +65,7 @@ runtime·SysMap(void *v, uintptr n) ...@@ -65,7 +65,7 @@ runtime·SysMap(void *v, uintptr n)
// On 64-bit, we don't actually have v reserved, so tread carefully. // On 64-bit, we don't actually have v reserved, so tread carefully.
if(sizeof(void*) == 8) { if(sizeof(void*) == 8) {
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0); p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(p == (void*)-ENOMEM) if(p == (void*)-ENOMEM)
runtime·throw("runtime: out of memory"); runtime·throw("runtime: out of memory");
if(p != v) { if(p != v) {
...@@ -75,7 +75,7 @@ runtime·SysMap(void *v, uintptr n) ...@@ -75,7 +75,7 @@ runtime·SysMap(void *v, uintptr n)
return; return;
} }
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0); p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
if(p == (void*)-ENOMEM) if(p == (void*)-ENOMEM)
runtime·throw("runtime: out of memory"); runtime·throw("runtime: out of memory");
if(p != v) if(p != v)
......
...@@ -19,7 +19,7 @@ runtime·SysAlloc(uintptr n) ...@@ -19,7 +19,7 @@ runtime·SysAlloc(uintptr n)
void *v; void *v;
mstats.sys += n; mstats.sys += n;
v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0); v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(v < (void*)4096) if(v < (void*)4096)
return nil; return nil;
return v; return v;
...@@ -65,7 +65,7 @@ runtime·SysMap(void *v, uintptr n) ...@@ -65,7 +65,7 @@ runtime·SysMap(void *v, uintptr n)
// On 64-bit, we don't actually have v reserved, so tread carefully. // On 64-bit, we don't actually have v reserved, so tread carefully.
if(sizeof(void*) == 8) { if(sizeof(void*) == 8) {
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0); p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(p == (void*)-ENOMEM) if(p == (void*)-ENOMEM)
runtime·throw("runtime: out of memory"); runtime·throw("runtime: out of memory");
if(p != v) { if(p != v) {
...@@ -75,7 +75,7 @@ runtime·SysMap(void *v, uintptr n) ...@@ -75,7 +75,7 @@ runtime·SysMap(void *v, uintptr n)
return; return;
} }
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0); p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
if(p == (void*)-ENOMEM) if(p == (void*)-ENOMEM)
runtime·throw("runtime: out of memory"); runtime·throw("runtime: out of memory");
if(p != v) if(p != v)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment