Bug 1576052 - Use configuration/macro definition to selectively enable wasm sandbox for graphite r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D43710

--HG--
extra : moz-landing-system : lando
This commit is contained in:
shravanrn@gmail.com 2019-12-19 22:17:13 +00:00
parent 9c408a861e
commit a3f185ef1b
8 changed files with 60 additions and 4 deletions

View file

@ -9,6 +9,7 @@ external_dirs = []
DIRS += [ DIRS += [
'lgpllibs', 'lgpllibs',
'rlbox', 'rlbox',
'rlbox_lucet_sandbox',
'sqlite', 'sqlite',
] ]
if not CONFIG['MOZ_SYSTEM_JPEG']: if not CONFIG['MOZ_SYSTEM_JPEG']:

View file

@ -0,0 +1,16 @@
# -*- 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/rust/rlbox_lucet_sandbox/include/lucet_sandbox.h',
'/third_party/rust/rlbox_lucet_sandbox/include/rlbox_lucet_sandbox.hpp',
]
SOURCES += [
'rlbox_lucet_thread_locals.cpp'
]
FINAL_LIBRARY = 'xul'

View file

@ -0,0 +1,20 @@
/* -*- 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
// Load general firefox configuration of RLBox
# include "mozilla/rlbox/rlbox_config.h"
# include "mozilla/rlbox/rlbox_lucet_sandbox.hpp"
# include "mozilla/rlbox/rlbox.hpp"
// 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_LUCET_SANDBOX_STATIC_VARIABLES();
#endif

View file

@ -11,9 +11,13 @@
// Load general firefox configuration of RLBox // Load general firefox configuration of RLBox
#include "mozilla/rlbox/rlbox_config.h" #include "mozilla/rlbox/rlbox_config.h"
#ifdef MOZ_WASM_SANDBOXING_GRAPHITE
# include "mozilla/rlbox/rlbox_lucet_sandbox.hpp"
#else
// Extra configuration for no-op sandbox // Extra configuration for no-op sandbox
#define RLBOX_USE_STATIC_CALLS() rlbox_noop_sandbox_lookup_symbol # define RLBOX_USE_STATIC_CALLS() rlbox_noop_sandbox_lookup_symbol
#include "mozilla/rlbox/rlbox_noop_sandbox.hpp" # include "mozilla/rlbox/rlbox_noop_sandbox.hpp"
#endif
#include "mozilla/rlbox/rlbox.hpp" #include "mozilla/rlbox/rlbox.hpp"

View file

@ -8,7 +8,15 @@
#include "mozilla/rlbox/rlbox_types.hpp" #include "mozilla/rlbox/rlbox_types.hpp"
#ifdef MOZ_WASM_SANDBOXING_GRAPHITE
namespace rlbox {
class rlbox_lucet_sandbox;
}
using rlbox_gr_sandbox_type = rlbox::rlbox_lucet_sandbox;
#else
using rlbox_gr_sandbox_type = rlbox::rlbox_noop_sandbox; using rlbox_gr_sandbox_type = rlbox::rlbox_noop_sandbox;
#endif
using rlbox_sandbox_gr = rlbox::rlbox_sandbox<rlbox_gr_sandbox_type>; using rlbox_sandbox_gr = rlbox::rlbox_sandbox<rlbox_gr_sandbox_type>;
template <typename T> template <typename T>
using sandbox_callback_gr = rlbox::sandbox_callback<T, rlbox_gr_sandbox_type>; using sandbox_callback_gr = rlbox::sandbox_callback<T, rlbox_gr_sandbox_type>;

View file

@ -609,7 +609,11 @@ struct gfxFontEntry::GrSandboxData {
grGetGlyphAdvanceCallback; grGetGlyphAdvanceCallback;
GrSandboxData() { GrSandboxData() {
#ifdef MOZ_WASM_SANDBOXING_GRAPHITE
# error "Sandboxed graphite not yet implemented"
#else
sandbox.create_sandbox(); sandbox.create_sandbox();
#endif
grGetTableCallback = sandbox.register_callback(GrGetTable); grGetTableCallback = sandbox.register_callback(GrGetTable);
grReleaseTableCallback = sandbox.register_callback(GrReleaseTable); grReleaseTableCallback = sandbox.register_callback(GrReleaseTable);
grGetGlyphAdvanceCallback = grGetGlyphAdvanceCallback =

View file

@ -73,3 +73,6 @@ if CONFIG['ENABLE_REMOTE_AGENT']:
if CONFIG['MOZ_FOGOTYPE']: if CONFIG['MOZ_FOGOTYPE']:
gkrust_features += ['fogotype'] gkrust_features += ['fogotype']
if CONFIG['MOZ_USING_WASM_SANDBOXING']:
gkrust_features += ['wasm_library_sandboxing']

View file

@ -1767,8 +1767,7 @@ def has_remote(toolkit):
set_config('MOZ_HAS_REMOTE', has_remote) set_config('MOZ_HAS_REMOTE', has_remote)
set_define('MOZ_HAS_REMOTE', has_remote) set_define('MOZ_HAS_REMOTE', has_remote)
# RLBox Library Sandboxing wasm support
# wasm sandboxing support
# ============================================================== # ==============================================================
def wasm_sandboxing_libraries(): def wasm_sandboxing_libraries():
@ -1785,6 +1784,7 @@ def requires_wasm_sandboxing(libraries):
return True return True
set_config('MOZ_USING_WASM_SANDBOXING', requires_wasm_sandboxing) set_config('MOZ_USING_WASM_SANDBOXING', requires_wasm_sandboxing)
set_define('MOZ_USING_WASM_SANDBOXING', requires_wasm_sandboxing)
lucetc = check_prog('LUCETC', ['lucetc'], lucetc = check_prog('LUCETC', ['lucetc'],
paths=toolchain_search_path, when=requires_wasm_sandboxing) paths=toolchain_search_path, when=requires_wasm_sandboxing)