js: Support for the MPROTECT security feature (PaX and NetBSD)

On such platforms, remapping memory that was once writable
to executable is forbidden unless the initial mmap() is declared
to change in such a way using the PROT_MPROTECT macro.
This commit is contained in:
Nia Alarie
2024-09-12 09:42:44 +02:00
committed by roytam1
parent ec8793a094
commit dd6526daae
2 changed files with 20 additions and 2 deletions
+6 -1
View File
@@ -644,7 +644,12 @@ WasmArrayRawBuffer::Allocate(uint32_t numBytes, Maybe<uint32_t> maxSize)
return nullptr;
}
# else // XP_WIN
void* data = MozTaggedAnonymousMmap(nullptr, (size_t) mappedSizeWithHeader, PROT_NONE,
void* data = MozTaggedAnonymousMmap(nullptr, (size_t) mappedSizeWithHeader,
#ifdef PROT_MPROTECT
PROT_MPROTECT(PROT_EXEC | PROT_WRITE | PROT_READ),
#else
PROT_NONE,
#endif
MAP_PRIVATE | MAP_ANON, -1, 0, "wasm-reserved");
if (data == MAP_FAILED)
return nullptr;