Bug 1642721 - convert security.sandbox.logging.enabled to a StaticPref. r=bobowen

Depends on D78933

Differential Revision: https://phabricator.services.mozilla.com/D78934
This commit is contained in:
Alexis Beingessner 2020-06-11 12:35:45 +00:00
Родитель 83994a45b8
Коммит 0d843d258d
3 изменённых файлов: 19 добавлений и 21 удалений

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

@ -1021,12 +1021,6 @@ pref("dom.ipc.shims.enabledWarnings", false);
// SetSecurityLevelForContentProcess() for what the different settings mean.
pref("security.sandbox.content.level", 6);
// This controls the depth of stack trace that is logged when Windows sandbox
// logging is turned on. This is only currently available for the content
// process because the only other sandbox (for GMP) has too strict a policy to
// allow stack tracing. This does not require a restart to take effect.
pref("security.sandbox.windows.log.stackTraceDepth", 0);
// This controls the strength of the Windows GPU process sandbox. Changes
// will require restart.
// For information on what the level number means, see

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

@ -8779,6 +8779,15 @@
type: RelaxedAtomicBool
value: true
mirror: always
# This controls the depth of stack trace that is logged when Windows sandbox
# logging is turned on. This is only currently available for the content
# process because the only other sandbox (for GMP) has too strict a policy to
# allow stack tracing. This does not require a restart to take effect.
- name: security.sandbox.windows.log.stackTraceDepth
type: RelaxedAtomicUint32
value: 0
mirror: always
#endif
# When comparing schemes, if this pref is set, view-source URIs are reachable

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

@ -11,6 +11,7 @@
#include "mozilla/Logging.h"
#include "mozilla/Preferences.h"
#include "mozilla/StaticPrefs_security.h"
#include "mozilla/sandboxing/loggingTypes.h"
#include "nsContentUtils.h"
@ -24,8 +25,6 @@ static LazyLogModule sSandboxTargetLog("SandboxTarget");
namespace sandboxing {
static uint32_t sStackTraceDepth = 0;
// NS_WalkStackCallback to write a formatted stack frame to an ostringstream.
static void
StackFrameToOStringStream(uint32_t aFrameNumber, void* aPC, void* aSP,
@ -54,14 +53,19 @@ Log(const char* aMessageType,
msgStream << " for : " << aContext;
}
if (aShouldLogStackTrace) {
if (sStackTraceDepth) {
#if defined(MOZ_SANDBOX)
// We can only log the stack trace on process types where we know that the
// sandbox won't prevent it.
if (XRE_IsContentProcess() && aShouldLogStackTrace) {
auto stackTraceDepth =
StaticPrefs::security_sandbox_windows_log_stackTraceDepth();
if (stackTraceDepth) {
msgStream << std::endl << "Stack Trace:";
MozStackWalk(StackFrameToOStringStream, aFramesToSkip, sStackTraceDepth,
MozStackWalk(StackFrameToOStringStream, aFramesToSkip, stackTraceDepth,
&msgStream);
}
}
#endif
std::string msg = msgStream.str();
#if defined(DEBUG)
// Use NS_DebugBreak directly as we want child process prefix, but not source
@ -88,15 +92,6 @@ InitLoggingIfRequired(ProvideLogFunctionCb aProvideLogFunctionCb)
if (Preferences::GetBool("security.sandbox.logging.enabled") ||
PR_GetEnv("MOZ_SANDBOX_LOGGING")) {
aProvideLogFunctionCb(Log);
#if defined(MOZ_SANDBOX)
// We can only log the stack trace on process types where we know that the
// sandbox won't prevent it.
if (XRE_IsContentProcess()) {
Preferences::AddUintVarCache(&sStackTraceDepth,
"security.sandbox.windows.log.stackTraceDepth");
}
#endif
}
}