summaryrefslogtreecommitdiffstats
path: root/config/external/rlbox_wasm2c_sandbox
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--config/external/rlbox_wasm2c_sandbox/moz.build13
-rw-r--r--config/external/rlbox_wasm2c_sandbox/moz.yaml36
-rw-r--r--config/external/rlbox_wasm2c_sandbox/rlbox_wasm2c_thread_locals.cpp44
3 files changed, 93 insertions, 0 deletions
diff --git a/config/external/rlbox_wasm2c_sandbox/moz.build b/config/external/rlbox_wasm2c_sandbox/moz.build
new file mode 100644
index 0000000000..c50c47f94e
--- /dev/null
+++ b/config/external/rlbox_wasm2c_sandbox/moz.build
@@ -0,0 +1,13 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+EXPORTS.mozilla.rlbox += [
+ "/third_party/rlbox_wasm2c_sandbox/include/rlbox_wasm2c_sandbox.hpp",
+]
+
+SOURCES += ["rlbox_wasm2c_thread_locals.cpp"]
+
+FINAL_LIBRARY = "xul"
diff --git a/config/external/rlbox_wasm2c_sandbox/moz.yaml b/config/external/rlbox_wasm2c_sandbox/moz.yaml
new file mode 100644
index 0000000000..99a7a34096
--- /dev/null
+++ b/config/external/rlbox_wasm2c_sandbox/moz.yaml
@@ -0,0 +1,36 @@
+schema: 1
+
+bugzilla:
+ product: Core
+ component: "General"
+
+origin:
+ name: rlbox_wasm2c_sandbox
+ description: rlbox integration for the wasm2c sandboxed code
+ url: https://github.com/PLSysSec/rlbox_wasm2c_sandbox
+
+ release: commit 54e8469095e7929c66aeecdc26f23f502b986218 (2021-12-08T08:12:13Z).
+ revision: 54e8469095e7929c66aeecdc26f23f502b986218
+
+ license: MIT
+ license-file: LICENSE
+
+vendoring:
+ url: https://github.com/PLSysSec/rlbox_wasm2c_sandbox
+ source-hosting: github
+ vendor-directory: third_party/rlbox_wasm2c_sandbox
+
+ exclude:
+ # dirs
+ - test
+ # files
+ - .clang-format
+ - .clang-tidy
+ - .gitignore
+ - .travis.yml
+ - AppSandbox.md
+ - CMakeLists.txt
+ - LibrarySandbox.md
+ - README.md
+
+
diff --git a/config/external/rlbox_wasm2c_sandbox/rlbox_wasm2c_thread_locals.cpp b/config/external/rlbox_wasm2c_sandbox/rlbox_wasm2c_thread_locals.cpp
new file mode 100644
index 0000000000..d7770ab5f1
--- /dev/null
+++ b/config/external/rlbox_wasm2c_sandbox/rlbox_wasm2c_thread_locals.cpp
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifdef MOZ_USING_WASM_SANDBOXING
+
+// For MOZ_CRASH_UNSAFE_PRINTF
+# include "mozilla/Assertions.h"
+
+// Load general firefox configuration of RLBox
+# include "mozilla/rlbox/rlbox_config.h"
+
+# include "mozilla/rlbox/rlbox_wasm2c_sandbox.hpp"
+
+# include "mozilla/rlbox/rlbox.hpp"
+
+# include "nsExceptionHandler.h"
+
+// The MingW compiler does not correctly handle static thread_local inline
+// members. We instead TLS storage via functions. This can be removed if the
+// MingW bug is fixed.
+RLBOX_WASM2C_SANDBOX_STATIC_VARIABLES();
+
+extern "C" {
+
+// Any error encountered by the wasm2c runtime or wasm sandboxed library code
+// is configured to call the below trap handler.
+void moz_wasm2c_trap_handler(const char* msg) {
+ MOZ_CRASH_UNSAFE_PRINTF("wasm2c crash: %s", msg);
+}
+
+// The below function is called if a malloc in sandboxed code returns null
+// This indicates that the sandbox has run out of memory.
+void moz_wasm2c_malloc_failed(uint32_t size) {
+ // We don't use the allocation size information for now
+ (void)size;
+
+ CrashReporter::AnnotateCrashReport(
+ CrashReporter::Annotation::WasmLibrarySandboxMallocFailed, true);
+}
+}
+
+#endif