From: Alex Brainman Date: Fri, 17 May 2013 03:37:30 +0000 (+1000) Subject: runtime: do not mark os memory as executable on windows X-Git-Tag: go1.2rc2~1490 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=28f74608b5ab87cce5e19d91de915649bf4d0865;p=gostls13.git runtime: do not mark os memory as executable on windows R=golang-dev, bradfitz, khr CC=golang-dev https://golang.org/cl/9235046 --- diff --git a/src/pkg/runtime/mem_windows.c b/src/pkg/runtime/mem_windows.c index 7840daa22c..7ac0c6aaf1 100644 --- a/src/pkg/runtime/mem_windows.c +++ b/src/pkg/runtime/mem_windows.c @@ -13,6 +13,7 @@ enum { MEM_RESERVE = 0x2000, MEM_RELEASE = 0x8000, + PAGE_READWRITE = 0x0004, PAGE_EXECUTE_READWRITE = 0x40, }; @@ -25,7 +26,7 @@ void* runtime·SysAlloc(uintptr n) { mstats.sys += n; - return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, (uintptr)(MEM_COMMIT|MEM_RESERVE), (uintptr)PAGE_EXECUTE_READWRITE); + return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, (uintptr)(MEM_COMMIT|MEM_RESERVE), (uintptr)PAGE_READWRITE); } void @@ -51,12 +52,12 @@ runtime·SysReserve(void *v, uintptr n) { // v is just a hint. // First try at v. - v = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, (uintptr)MEM_RESERVE, (uintptr)PAGE_EXECUTE_READWRITE); + v = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, (uintptr)MEM_RESERVE, (uintptr)PAGE_READWRITE); if(v != nil) return v; // Next let the kernel choose the address. - return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, (uintptr)MEM_RESERVE, (uintptr)PAGE_EXECUTE_READWRITE); + return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, (uintptr)MEM_RESERVE, (uintptr)PAGE_READWRITE); } void @@ -65,7 +66,7 @@ runtime·SysMap(void *v, uintptr n) void *p; mstats.sys += n; - p = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, (uintptr)MEM_COMMIT, (uintptr)PAGE_EXECUTE_READWRITE); + p = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, (uintptr)MEM_COMMIT, (uintptr)PAGE_READWRITE); if(p != v) runtime·throw("runtime: cannot map pages in arena address space"); }