W^X support (#54954)
authorJan Vorlicek <jan.vorlicek@volny.cz>
Sun, 11 Jul 2021 14:46:53 +0000 (16:46 +0200)
committerGitHub <noreply@github.com>
Sun, 11 Jul 2021 14:46:53 +0000 (16:46 +0200)
commit6a47ecf4a8ee670356f5e554f08afb0b32cdac9a
treeeee15291b1ce2ad0c90c2e13b646d6e83fdf472b
parent83a4d3cc02fb04fce17b24fc09b3cdf77a12ba51
W^X support (#54954)

* W^X support

This change is the last part of enabling the W^X support. It adds the
actual executable allocator that handles all double mapped memory
allocations and creating the writeable mappings.

The platform specific functionality is placed in a new minipal that is
going to be a basis for future removal of Windows APIs usage from the
native runtime.

The last state of the change was tested on all the platforms that we
support using coreclr pri 1 tests with both the W^X enabled and disabled
using the COMPlus_EnableWriteXorExecute variable.

The debugger changes were tested using the managed debugger testing
suite on Windows x64, x86 and on Apple Silicon so far. Further testing
on other platforms is in progress.

* Replace LeafLock in UMEntryThunkFreeList by a new lock

* Also allocate LoaderHeapFreeBlock from regular heap.

* Set the W^X default to disabled
70 files changed:
src/coreclr/CMakeLists.txt
src/coreclr/clrdefinitions.cmake
src/coreclr/debug/ee/arm64/arm64walker.cpp
src/coreclr/debug/ee/controller.cpp
src/coreclr/debug/ee/controller.h
src/coreclr/debug/ee/debugger.cpp
src/coreclr/debug/ee/debugger.h
src/coreclr/debug/inc/amd64/primitives.h
src/coreclr/debug/inc/arm/primitives.h
src/coreclr/debug/inc/arm64/primitives.h
src/coreclr/debug/inc/i386/primitives.h
src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
src/coreclr/inc/CrstTypes.def
src/coreclr/inc/clrconfigvalues.h
src/coreclr/inc/crsttypes.h
src/coreclr/inc/executableallocator.h
src/coreclr/inc/jithelpers.h
src/coreclr/inc/utilcode.h
src/coreclr/minipal/CMakeLists.txt [new file with mode: 0644]
src/coreclr/minipal/Unix/CMakeLists.txt [new file with mode: 0644]
src/coreclr/minipal/Unix/doublemapping.cpp [new file with mode: 0644]
src/coreclr/minipal/Windows/CMakeLists.txt [new file with mode: 0644]
src/coreclr/minipal/Windows/doublemapping.cpp [new file with mode: 0644]
src/coreclr/minipal/minipal.h [new file with mode: 0644]
src/coreclr/utilcode/CMakeLists.txt
src/coreclr/utilcode/executableallocator.cpp [new file with mode: 0644]
src/coreclr/utilcode/loaderheap.cpp
src/coreclr/utilcode/util.cpp
src/coreclr/vm/CMakeLists.txt
src/coreclr/vm/amd64/JitHelpers_Fast.asm
src/coreclr/vm/amd64/jithelpers_fast.S
src/coreclr/vm/amd64/jitinterfaceamd64.cpp
src/coreclr/vm/arm/armsinglestepper.cpp
src/coreclr/vm/arm/asmhelpers.S
src/coreclr/vm/arm/asmhelpers.asm
src/coreclr/vm/arm/cgencpu.h
src/coreclr/vm/arm/stubs.cpp
src/coreclr/vm/arm64/arm64singlestepper.cpp
src/coreclr/vm/arm64/asmhelpers.S
src/coreclr/vm/arm64/asmhelpers.asm
src/coreclr/vm/arm64/cgencpu.h
src/coreclr/vm/arm64/stubs.cpp
src/coreclr/vm/ceemain.cpp
src/coreclr/vm/class.cpp
src/coreclr/vm/codeman.cpp
src/coreclr/vm/comcallablewrapper.cpp
src/coreclr/vm/comcallablewrapper.h
src/coreclr/vm/comdelegate.cpp
src/coreclr/vm/dllimportcallback.cpp
src/coreclr/vm/dynamicmethod.cpp
src/coreclr/vm/excep.cpp
src/coreclr/vm/exceptionhandling.cpp
src/coreclr/vm/gccover.cpp
src/coreclr/vm/i386/jithelp.S
src/coreclr/vm/i386/jithelp.asm
src/coreclr/vm/i386/jitinterfacex86.cpp
src/coreclr/vm/i386/stublinkerx86.cpp
src/coreclr/vm/i386/stublinkerx86.h
src/coreclr/vm/jitinterface.cpp
src/coreclr/vm/jitinterface.h
src/coreclr/vm/loaderallocator.cpp
src/coreclr/vm/loaderallocator.inl
src/coreclr/vm/method.cpp
src/coreclr/vm/precode.cpp
src/coreclr/vm/stackwalk.cpp
src/coreclr/vm/stublink.cpp
src/coreclr/vm/stublink.h
src/coreclr/vm/threads.cpp
src/coreclr/vm/threads.h
src/coreclr/vm/virtualcallstub.cpp