diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /config/external/rlbox_wasm2c_sandbox | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'config/external/rlbox_wasm2c_sandbox')
-rw-r--r-- | config/external/rlbox_wasm2c_sandbox/moz.build | 24 | ||||
-rw-r--r-- | config/external/rlbox_wasm2c_sandbox/moz.yaml | 34 | ||||
-rw-r--r-- | config/external/rlbox_wasm2c_sandbox/rlbox_wasm2c_thread_locals.cpp | 48 |
3 files changed, 106 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..02e09973a7 --- /dev/null +++ b/config/external/rlbox_wasm2c_sandbox/moz.build @@ -0,0 +1,24 @@ +# -*- 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", + "/third_party/rlbox_wasm2c_sandbox/include/rlbox_wasm2c_tls.hpp", +] +EXPORTS += [ + "/third_party/rlbox_wasm2c_sandbox/include/wasm2c_rt_mem.h", + "/third_party/rlbox_wasm2c_sandbox/include/wasm2c_rt_minwasi.h", +] + +SOURCES += [ + "/third_party/rlbox_wasm2c_sandbox/src/wasm2c_rt_mem.c", + "/third_party/rlbox_wasm2c_sandbox/src/wasm2c_rt_minwasi.c", + "rlbox_wasm2c_thread_locals.cpp", +] + +LOCAL_INCLUDES += ["/third_party/wasm2c/wasm2c/"] + +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..ffded2a0e3 --- /dev/null +++ b/config/external/rlbox_wasm2c_sandbox/moz.yaml @@ -0,0 +1,34 @@ +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/tree/upstream-wasm2c + + release: 7e4ff0ebca2c7644a297bfe51a53b9904f0999b2 (2023-04-13T05:07:28Z). + revision: 7e4ff0ebca2c7644a297bfe51a53b9904f0999b2 + + 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..f37a868406 --- /dev/null +++ b/config/external/rlbox_wasm2c_sandbox/rlbox_wasm2c_thread_locals.cpp @@ -0,0 +1,48 @@ +/* -*- 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" + +# include "mozilla/mozalloc_oom.h" + +// Load general firefox configuration of RLBox +# include "mozilla/rlbox/rlbox_config.h" +# include "mozilla/rlbox/rlbox_wasm2c_tls.hpp" +# include "wasm-rt.h" + +# 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(wasm_rt_trap_t code) { + MOZ_CRASH_UNSAFE_PRINTF("wasm2c crash: %s", wasm_rt_strerror(code)); +} + +// 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_memgrow_failed() { + CrashReporter::AnnotateCrashReport( + CrashReporter::Annotation::WasmLibrarySandboxMallocFailed, true); +} + +// This function is called when mozalloc_handle_oom is called from within +// the sandbox. We redirect to that function, ignoring the ctx argument, which +// is the sandbox itself. +void w2c_env_mozalloc_handle_oom(void* ctx, uint32_t size) { + mozalloc_handle_oom(size); +} +} + +#endif |