Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(685)

Side by Side Diff: src/pkg/runtime/mem_linux.c

Issue 7405045: code review 7405045: runtime: remove PROT_EXEC from mmap calls. (Closed)
Patch Set: diff -r d7ae1953ef1b https://code.google.com/p/go/ Created 12 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/runtime/mem_freebsd.c ('k') | src/pkg/runtime/mem_netbsd.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include "runtime.h" 5 #include "runtime.h"
6 #include "arch_GOARCH.h" 6 #include "arch_GOARCH.h"
7 #include "defs_GOOS_GOARCH.h" 7 #include "defs_GOOS_GOARCH.h"
8 #include "os_GOOS.h" 8 #include "os_GOOS.h"
9 #include "malloc.h" 9 #include "malloc.h"
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 return p; 51 return p;
52 } 52 }
53 53
54 void* 54 void*
55 runtime·SysAlloc(uintptr n) 55 runtime·SysAlloc(uintptr n)
56 { 56 {
57 void *p; 57 void *p;
58 58
59 mstats.sys += n; 59 mstats.sys += n;
60 » p = runtime·mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PR IVATE, -1, 0); 60 » p = runtime·mmap(nil, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
61 if(p < (void*)4096) { 61 if(p < (void*)4096) {
62 if(p == (void*)EACCES) { 62 if(p == (void*)EACCES) {
63 runtime·printf("runtime: mmap: access denied\n"); 63 runtime·printf("runtime: mmap: access denied\n");
64 runtime·printf("if you're running SELinux, enable execme m for this process.\n"); 64 runtime·printf("if you're running SELinux, enable execme m for this process.\n");
65 runtime·exit(2); 65 runtime·exit(2);
66 } 66 }
67 if(p == (void*)EAGAIN) { 67 if(p == (void*)EAGAIN) {
68 runtime·printf("runtime: mmap: too much locked memory (c heck 'ulimit -l').\n"); 68 runtime·printf("runtime: mmap: too much locked memory (c heck 'ulimit -l').\n");
69 runtime·exit(2); 69 runtime·exit(2);
70 } 70 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 void 112 void
113 runtime·SysMap(void *v, uintptr n) 113 runtime·SysMap(void *v, uintptr n)
114 { 114 {
115 void *p; 115 void *p;
116 ········ 116 ········
117 mstats.sys += n; 117 mstats.sys += n;
118 118
119 // On 64-bit, we don't actually have v reserved, so tread carefully. 119 // On 64-bit, we don't actually have v reserved, so tread carefully.
120 if(sizeof(void*) == 8 && (uintptr)v >= 0xffffffffU) { 120 if(sizeof(void*) == 8 && (uintptr)v >= 0xffffffffU) {
121 » » p = mmap_fixed(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MA P_PRIVATE, -1, 0); 121 » » p = mmap_fixed(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
122 if(p == (void*)ENOMEM) 122 if(p == (void*)ENOMEM)
123 runtime·throw("runtime: out of memory"); 123 runtime·throw("runtime: out of memory");
124 if(p != v) { 124 if(p != v) {
125 runtime·printf("runtime: address space conflict: map(%p) = %p\n", v, p); 125 runtime·printf("runtime: address space conflict: map(%p) = %p\n", v, p);
126 runtime·throw("runtime: address space conflict"); 126 runtime·throw("runtime: address space conflict");
127 } 127 }
128 return; 128 return;
129 } 129 }
130 130
131 » p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXE D|MAP_PRIVATE, -1, 0); 131 » p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_PRIV ATE, -1, 0);
132 if(p == (void*)ENOMEM) 132 if(p == (void*)ENOMEM)
133 runtime·throw("runtime: out of memory"); 133 runtime·throw("runtime: out of memory");
134 if(p != v) 134 if(p != v)
135 runtime·throw("runtime: cannot map pages in arena address space" ); 135 runtime·throw("runtime: cannot map pages in arena address space" );
136 } 136 }
OLDNEW
« no previous file with comments | « src/pkg/runtime/mem_freebsd.c ('k') | src/pkg/runtime/mem_netbsd.c » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b