diff options
author | Jan Vorlicek <jan.vorlicek@volny.cz> | 2021-06-10 16:26:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-10 16:26:40 +0300 |
commit | d617e830ec621db80f6df9ed8ba75176f5ba6035 (patch) | |
tree | f2389aecbcca81cd24d0604263ea3bbc7ffab50c /src/coreclr/vm/ceemain.cpp | |
parent | 7b3564a3de6c5d50515b0be31aa14e52c257a44f (diff) |
Add writeable holders for executable memory (#53934)
* Add writeable holders for executable memory
This change adds holders for writeable mappings for executable memory.
It is the largest part of the W^X support. The ExecutableWriterHolder
implementation is dummy in this change, but it was fully tested with
coreclr / libraries tests on Windows arm, arm64, x64 and x86 with the
real double memory mapping.
There are few concepts / conventions used:
* When the writeable pointer isn't known at a place where it is needed
and also not at the caller, the ExecutableWriterHolder instance is
created.
* When a callee needs writeable pointer to executable memory and caller
knows RW and RX, the argument is doubled with RX and RW suffixes. For
constructors and member methods when "this" is the RW one, we pass just
extra RX argument.
* Locals holding RW pointer use RW suffix.
* Locals holding RX pointer usually have no suffix to minimize number of
changes, but in some cases they have a RX suffix
where I felt like it was better to make things clear.
Diffstat (limited to 'src/coreclr/vm/ceemain.cpp')
-rw-r--r-- | src/coreclr/vm/ceemain.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/coreclr/vm/ceemain.cpp b/src/coreclr/vm/ceemain.cpp index eb31d0f928d..6ccf233d9a3 100644 --- a/src/coreclr/vm/ceemain.cpp +++ b/src/coreclr/vm/ceemain.cpp @@ -489,15 +489,9 @@ void InitGSCookie() volatile GSCookie * pGSCookiePtr = GetProcessGSCookiePtr(); -#ifdef TARGET_UNIX - // On Unix, the GS cookie is stored in a read only data segment - DWORD newProtection = PAGE_READWRITE; -#else // TARGET_UNIX - DWORD newProtection = PAGE_EXECUTE_READWRITE; -#endif // !TARGET_UNIX - + // The GS cookie is stored in a read only data segment DWORD oldProtection; - if(!ClrVirtualProtect((LPVOID)pGSCookiePtr, sizeof(GSCookie), newProtection, &oldProtection)) + if(!ClrVirtualProtect((LPVOID)pGSCookiePtr, sizeof(GSCookie), PAGE_READWRITE, &oldProtection)) { ThrowLastError(); } |