Bug 1739298 - Configure RLBox to avoid using locks as it is only used in single threaded contexts r=bholley

Differential Revision: https://phabricator.services.mozilla.com/D130326
This commit is contained in:
shravanrn@gmail.com 2021-11-04 20:49:22 +00:00
Родитель 0b04ea1041
Коммит dfca79f9ba
7 изменённых файлов: 38 добавлений и 5 удалений

5
config/external/rlbox/rlbox_config.h поставляемый
Просмотреть файл

@ -29,8 +29,9 @@ struct rlbox_shared_lock {
#endif
// All uses are on the main thread right now, disable rlbox thread checks for
// performance
// All uses of rlbox's function and callbacks invocations are on a single
// thread right now, so we disable rlbox thread checks for performance
// See (Bug 1739298) for more details
#define RLBOX_SINGLE_THREADED_INVOCATIONS
#define RLBOX_CUSTOM_ABORT(msg) MOZ_CRASH_UNSAFE_PRINTF("RLBox crash: %s", msg)

Просмотреть файл

@ -9,8 +9,8 @@ origin:
description: rlbox integration for the wasm2c sandboxed code
url: https://github.com/PLSysSec/rlbox_wasm2c_sandbox
release: commit b716e3bc4c1b81b23241a0ffe96e41580f4528f1 (2021-10-15T07:27:02Z).
revision: b716e3bc4c1b81b23241a0ffe96e41580f4528f1
release: commit ba86ca0b51d3e2752bb0fb89acb968f8df754a6c (2021-11-04T19:35:57Z).
revision: ba86ca0b51d3e2752bb0fb89acb968f8df754a6c
license: MIT
license-file: LICENSE

2
third_party/rlbox/README-mozilla поставляемый
Просмотреть файл

@ -1,7 +1,7 @@
This directory contains the rlbox source from the upstream repo:
https://github.com/PLSysSec/rlbox_sandboxing_api/
Current version: [commit 71222a234ceae75ff70e09d0855ebeb3b4c961a7]
Current version: [commit 298c785d94fe3f502c52649be292fa9da71de2e9]
UPDATING:

Просмотреть файл

@ -90,7 +90,9 @@ private:
using T_Func = T_Ret (*)(T_Args...);
T_Func func;
{
#ifndef RLBOX_SINGLE_THREADED_INVOCATIONS
RLBOX_ACQUIRE_SHARED_GUARD(lock, thread_data.sandbox->callback_mutex);
#endif
func = reinterpret_cast<T_Func>(thread_data.sandbox->callbacks[N]);
}
// Callbacks are invoked through function pointers, cannot use std::forward

Просмотреть файл

@ -74,7 +74,9 @@ private:
using T_Func = T_Ret (*)(T_Args...);
T_Func func;
{
#ifndef RLBOX_SINGLE_THREADED_INVOCATIONS
RLBOX_ACQUIRE_SHARED_GUARD(lock, thread_data.sandbox->callback_mutex);
#endif
func = reinterpret_cast<T_Func>(thread_data.sandbox->callbacks[N]);
}
// Callbacks are invoked through function pointers, cannot use std::forward

24
third_party/rlbox/include/rlbox_types.hpp поставляемый
Просмотреть файл

@ -41,3 +41,27 @@ class rlbox_noop_sandbox;
class rlbox_dylib_sandbox;
}
#define RLBOX_DEFINE_SANDBOX_TYPE(SBXNAME, SBXTYPE) \
namespace rlbox { \
class rlbox_##SBXTYPE_sandbox; \
} \
using rlbox_##SBXNAME_sandbox_type = rlbox::rlbox_##SBXTYPE_sandbox;
#define RLBOX_DEFINE_BASE_TYPES_FOR(SBXNAME) \
using rlbox_sandbox_##SBXNAME = \
rlbox::rlbox_sandbox<rlbox_##SBXNAME_sandbox_type>; \
template <typename T> \
using sandbox_callback_##SBXNAME = \
rlbox::sandbox_callback<T, rlbox_##SBXNAME_sandbox_type>; \
template <typename T> \
using tainted_##SBXNAME = rlbox::tainted<T, rlbox_##SBXNAME_sandbox_type>; \
template <typename T> \
using tainted_opaque_##SBXNAME = \
rlbox::tainted_opaque<T, rlbox_##SBXNAME_sandbox_type>; \
template <typename T> \
using tainted_volatile_##SBXNAME = \
rlbox::tainted_volatile<T, rlbox_##SBXNAME_sandbox_type>; \
using rlbox::tainted_boolean_hint; \
template <typename T> \
using app_pointer_##SBXNAME = rlbox::app_pointer<T, rlbox_##SBXNAME_sandbox_type>;

Просмотреть файл

@ -303,7 +303,9 @@ __attribute__((weak))
using T_Func = T_Ret (*)(T_Args...);
T_Func func;
{
#ifndef RLBOX_SINGLE_THREADED_INVOCATIONS
RLBOX_ACQUIRE_SHARED_GUARD(lock, thread_data.sandbox->callback_mutex);
#endif
func = reinterpret_cast<T_Func>(thread_data.sandbox->callbacks[N]);
}
// Callbacks are invoked through function pointers, cannot use std::forward
@ -325,7 +327,9 @@ __attribute__((weak))
using T_Func = T_Ret (*)(T_Args...);
T_Func func;
{
#ifndef RLBOX_SINGLE_THREADED_INVOCATIONS
RLBOX_ACQUIRE_SHARED_GUARD(lock, thread_data.sandbox->callback_mutex);
#endif
func = reinterpret_cast<T_Func>(thread_data.sandbox->callbacks[N]);
}
// Callbacks are invoked through function pointers, cannot use std::forward