Workaround problems with hardened runtime, needed for notarization #259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On macOS 10.15 Catalina and later applications need to be Notarized where notarization is an Apple malware- and security-check of the released binaries.
As part of the notarization process, Apple require that hardened runtime is enabled. This prevents
Currently
hyperkit
usesvalloc
to allocate memory for the VM and then grants the VMREAD
,WRITE
andEXECUTE
, which will fail if the hardened runtime is enabled.One workaround is to grant the
hyperkit
binary the Allow Unsigned Executable Memory Entitlement which disables the writable+executable check for all allocations done by the process.This patch proposes another workaround, which is to switch from using
valloc
tommap
with the special flagMAP_JIT
. This allows us to use the weaker Allow Execution of JIT-compiled Code entitlement, so that only the VM memory allocation is writable+executable, other allocations are not.Note that, according to the mono project mono/mono@a502768 the
MAP_JIT
flag causes problems with older version of macOS, so they recommend only enabling it for Mojave and later.Note that enabling the hardened runtime and adding entitlements is done at the
codesign
stage which means we can't easily test this from the current CI as the binaries are unsigned.