openbsd-ports/lang/node/patches/patch-deps_v8_src_execution_isolate_cc
robert 2aba169072 put the embedded blob code to the .openbsd.mutable section and
mprotect it RX to support x-only

idea from deraadt@, diff from kettenis@
2023-01-28 12:46:46 +00:00

27 lines
940 B
Plaintext

Index: deps/v8/src/execution/isolate.cc
--- deps/v8/src/execution/isolate.cc.orig
+++ deps/v8/src/execution/isolate.cc
@@ -141,6 +141,10 @@
#include "src/execution/simulator-base.h"
#endif
+#if defined(V8_OS_OPENBSD)
+#include <sys/mman.h>
+#endif
+
extern "C" const uint8_t* v8_Default_embedded_blob_code_;
extern "C" uint32_t v8_Default_embedded_blob_code_size_;
extern "C" const uint8_t* v8_Default_embedded_blob_data_;
@@ -3682,6 +3686,11 @@ void Isolate::InitializeDefaultEmbeddedBlob() {
uint32_t code_size = DefaultEmbeddedBlobCodeSize();
const uint8_t* data = DefaultEmbeddedBlobData();
uint32_t data_size = DefaultEmbeddedBlobDataSize();
+
+#if defined(V8_OS_OPENBSD)
+ mprotect(reinterpret_cast<void *>(const_cast<uint8_t *>(code)),
+ code_size, PROT_READ | PROT_EXEC);
+#endif
if (StickyEmbeddedBlobCode() != nullptr) {
base::MutexGuard guard(current_embedded_blob_refcount_mutex_.Pointer());