Bug 1626174 - Enable use of wasm sandboxed libOgg in the OggDemuxer in linux, mac, try servers r=padenot,erahm,dmajor,firefox-build-system-reviewers

Depends on D68764

Differential Revision: https://phabricator.services.mozilla.com/D70652
This commit is contained in:
shravanrn@gmail.com 2020-04-21 15:30:37 +00:00
Родитель d2d2282d1c
Коммит f0399f4146
10 изменённых файлов: 55 добавлений и 22 удалений

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

@ -1,7 +1,7 @@
export TOOLTOOL_DIR="$topsrcdir"
export LLVM_CONFIG="${MOZ_FETCHES_DIR}/clang/bin/llvm-config"
export WASM_SANDBOXED_LIBRARIES=graphite
export WASM_SANDBOXED_LIBRARIES=graphite,ogg
export LUCETC="${MOZ_FETCHES_DIR}/lucetc/lucetc"
export WASI_SYSROOT="${MOZ_FETCHES_DIR}/wasi-sysroot/share/wasi-sysroot"
export WASM_CC="${MOZ_FETCHES_DIR}/clang/bin/clang --target=wasm32-wasi"

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

@ -108,6 +108,9 @@
#ifdef MOZ_WASM_SANDBOXING_GRAPHITE
@BINPATH@/@DLL_PREFIX@graphitewasm@DLL_SUFFIX@
#endif
#ifdef MOZ_WASM_SANDBOXING_OGG
@BINPATH@/@DLL_PREFIX@oggwasm@DLL_SUFFIX@
#endif
; We don't have a complete view of which dlls to expect when doing an artifact
; build because we haven't run the relevant parts of configure, so we guess

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

@ -41,7 +41,7 @@ unset RANLIB
unset NASM
# Don't unset this on Linux artifact builds so the artifact builds correctly
# package the graphite shared library.
# package any Wasm sandboxed shared libraries.
if test `uname -s` != Linux; then
unset WASM_SANDBOXED_LIBRARIES
fi

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

@ -4,7 +4,7 @@ base-toolchains*)
# Clang versions < 8.0 don't support wasm.
;;
*)
export WASM_SANDBOXED_LIBRARIES=graphite
export WASM_SANDBOXED_LIBRARIES=graphite,ogg
export WASM_CC="${MOZ_FETCHES_DIR}/clang/bin/clang --target=wasm32-wasi"
export WASM_CXX="${MOZ_FETCHES_DIR}/clang/bin/clang++ --target=wasm32-wasi"
export LUCETC="${MOZ_FETCHES_DIR}/lucetc/lucetc"

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

@ -16,6 +16,9 @@
#include "mozilla/SharedThreadPool.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TimeStamp.h"
#ifdef MOZ_WASM_SANDBOXING_OGG
# include "mozilla/ipc/LibrarySandboxPreload.h"
#endif
#include "nsAutoRef.h"
#include "nsError.h"

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

@ -12,50 +12,69 @@
namespace mozilla {
namespace ipc {
nsAutoCString GetSandboxedGraphitePath() {
static nsAutoCString GetSandboxedPath(const nsACString& libName) {
nsCOMPtr<nsIFile> binaryPath;
nsresult rv = mozilla::BinaryPath::GetFile(getter_AddRefs(binaryPath));
if (NS_FAILED(rv)) {
MOZ_CRASH("Library preload failure: Failed to get binary file\n");
}
nsCOMPtr<nsIFile> graphiteFile;
rv = binaryPath->GetParent(getter_AddRefs(graphiteFile));
nsCOMPtr<nsIFile> libFile;
rv = binaryPath->GetParent(getter_AddRefs(libFile));
if (NS_FAILED(rv)) {
MOZ_CRASH("Library preload failure: Failed to get binary folder\n");
}
rv = graphiteFile->AppendNative(
NS_LITERAL_CSTRING(MOZ_DLL_PREFIX "graphitewasm" MOZ_DLL_SUFFIX));
rv = libFile->AppendNative(libName);
if (NS_FAILED(rv)) {
MOZ_CRASH("Library preload failure: Failed to get libgraphite file");
MOZ_CRASH("Library preload failure: Failed to get library file\n");
}
nsAutoString path;
rv = graphiteFile->GetPath(path);
nsAutoString fullPath;
rv = libFile->GetPath(fullPath);
if (NS_FAILED(rv)) {
MOZ_CRASH("Library preload failure: Failed to get libgraphite path\n");
MOZ_CRASH("Library preload failure: Failed to get library path\n");
}
nsAutoCString converted_path = NS_ConvertUTF16toUTF8(path);
nsAutoCString converted_path = NS_ConvertUTF16toUTF8(fullPath);
return converted_path;
}
nsAutoCString GetSandboxedGraphitePath() {
return GetSandboxedPath(
NS_LITERAL_CSTRING(MOZ_DLL_PREFIX "graphitewasm" MOZ_DLL_SUFFIX));
}
nsAutoCString GetSandboxedOggPath() {
return GetSandboxedPath(
NS_LITERAL_CSTRING(MOZ_DLL_PREFIX "oggwasm" MOZ_DLL_SUFFIX));
}
static PRLibrary* PreloadLibrary(const nsAutoCString& path) {
PRLibSpec libSpec;
libSpec.type = PR_LibSpec_Pathname;
libSpec.value.pathname = path.get();
PRLibrary* ret = PR_LoadLibraryWithFlags(libSpec, PR_LD_LAZY);
return ret;
}
void PreloadSandboxedDynamicLibraries() {
// The process level sandbox does not allow loading of dynamic libraries.
// This preloads wasm sandboxed libraries before the process level sandbox is
// enabled. Currently, this is only needed for Linux as Mac allows loading
// libraries from the package file.
#if defined(XP_LINUX) && defined(MOZ_WASM_SANDBOXING_GRAPHITE)
nsAutoCString path = GetSandboxedGraphitePath();
PRLibSpec libSpec;
libSpec.type = PR_LibSpec_Pathname;
libSpec.value.pathname = path.get();
PRLibrary* ret = PR_LoadLibraryWithFlags(libSpec, PR_LD_LAZY);
if (!ret) {
#if defined(XP_LINUX)
# if defined(MOZ_WASM_SANDBOXING_GRAPHITE)
if (!PreloadLibrary(GetSandboxedGraphitePath())) {
MOZ_CRASH("Library preload failure: Failed to load libgraphite\n");
}
# endif
# if defined(MOZ_WASM_SANDBOXING_OGG)
if (!PreloadLibrary(GetSandboxedOggPath())) {
MOZ_CRASH("Library preload failure: Failed to load libogg\n");
}
# endif
#endif
}

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

@ -11,6 +11,7 @@
namespace mozilla {
namespace ipc {
nsAutoCString GetSandboxedGraphitePath();
nsAutoCString GetSandboxedOggPath();
void PreloadSandboxedDynamicLibraries();
} // namespace ipc
} // namespace mozilla

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

@ -14,12 +14,18 @@ EXPORTS.ogg += [
'include/ogg/os_types.h',
]
UNIFIED_SOURCES += [
all_sources = [
'src/ogg_alloc.c',
'src/ogg_bitwise.c',
'src/ogg_framing.c',
]
UNIFIED_SOURCES += all_sources
if CONFIG['MOZ_WASM_SANDBOXING_OGG']:
SANDBOXED_WASM_LIBRARY_NAME = 'oggwasm'
WASM_SOURCES += all_sources
FINAL_LIBRARY = 'gkmedias'
# Add libFuzzer configuration directives

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

@ -477,6 +477,7 @@ class MacArtifactJob(ArtifactJob):
# 'libreplace_malloc.dylib',
'libmozavutil.dylib',
'libmozavcodec.dylib',
'liboggwasm.dylib',
'libosclientcerts.dylib',
'libsoftokn3.dylib',
'minidump-analyzer',

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

@ -1788,7 +1788,7 @@ set_define('MOZ_HAS_REMOTE', has_remote)
# ==============================================================
def wasm_sandboxing_libraries():
return ('graphite',)
return ('graphite', 'ogg',)
option('--with-wasm-sandboxed-libraries',
env='WASM_SANDBOXED_LIBRARIES',