Bug 1268733 - Move sandbox telemetry / crash annotation code from mozsandbox to libxul. r=haik

This commit is contained in:
Jed Davis 2016-10-26 16:57:10 -06:00
Родитель 94ff9c7d97
Коммит 13fea0b617
4 изменённых файлов: 27 добавлений и 47 удалений

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

@ -1423,7 +1423,11 @@ ContentChild::RecvSetProcessSandbox(const MaybeFileDesc& aBroker)
NS_LITERAL_CSTRING("ContentSandboxEnabled"),
sandboxEnabled? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0"));
#if defined(XP_LINUX) && !defined(OS_ANDROID)
SandboxInfo::Get().AnnotateCrashReport();
nsAutoCString flagsString;
flagsString.AppendInt(SandboxInfo::Get().AsInteger());
CrashReporter::AnnotateCrashReport(
NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString);
#endif /* XP_LINUX && !OS_ANDROID */
#endif /* MOZ_CRASHREPORTER */
#endif /* MOZ_CONTENT_SANDBOX */

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

@ -19,18 +19,9 @@
#include "base/posix/eintr_wrapper.h"
#include "mozilla/Assertions.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Telemetry.h"
#include "sandbox/linux/system_headers/linux_seccomp.h"
#include "sandbox/linux/system_headers/linux_syscalls.h"
#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
#include "nsICrashReporter.h"
#define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1"
#include "nsIPrefService.h"
#include "nsIMemoryInfoDumper.h"
#endif
#ifdef MOZ_VALGRIND
#include <valgrind/valgrind.h>
#endif
@ -278,34 +269,4 @@ SandboxInfo::ThreadingCheck()
sSingleton.mFlags = static_cast<Flags>(flags);
}
/* static */ void
SandboxInfo::SubmitTelemetry()
{
SandboxInfo sandboxInfo = Get();
Telemetry::Accumulate(Telemetry::SANDBOX_HAS_SECCOMP_BPF,
sandboxInfo.Test(SandboxInfo::kHasSeccompBPF));
Telemetry::Accumulate(Telemetry::SANDBOX_HAS_SECCOMP_TSYNC,
sandboxInfo.Test(SandboxInfo::kHasSeccompTSync));
Telemetry::Accumulate(Telemetry::SANDBOX_HAS_USER_NAMESPACES_PRIVILEGED,
sandboxInfo.Test(SandboxInfo::kHasPrivilegedUserNamespaces));
Telemetry::Accumulate(Telemetry::SANDBOX_HAS_USER_NAMESPACES,
sandboxInfo.Test(SandboxInfo::kHasUserNamespaces));
Telemetry::Accumulate(Telemetry::SANDBOX_CONTENT_ENABLED,
sandboxInfo.Test(SandboxInfo::kEnabledForContent));
Telemetry::Accumulate(Telemetry::SANDBOX_MEDIA_ENABLED,
sandboxInfo.Test(SandboxInfo::kEnabledForMedia));
}
#ifdef MOZ_CRASHREPORTER
void
SandboxInfo::AnnotateCrashReport() const
{
nsAutoCString flagsString;
flagsString.AppendInt(mFlags);
CrashReporter::AnnotateCrashReport(
NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString);
}
#endif
} // namespace mozilla

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

@ -57,11 +57,10 @@ public:
return !Test(kEnabledForMedia) || Test(kHasSeccompBPF);
}
#ifdef MOZ_CRASHREPORTER
MOZ_EXPORT void AnnotateCrashReport() const;
#endif
static void SubmitTelemetry();
// For telemetry / crash annotation uses.
uint32_t AsInteger() const {
return mFlags;
}
// For bug 1222500 or anything else like it: On desktop, this is
// called in the parent process at a point when it should still be

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

@ -4434,9 +4434,25 @@ XREMain::XRE_mainRun()
#if defined(MOZ_SANDBOX) && defined(XP_LINUX) && !defined(MOZ_WIDGET_GONK)
// If we're on Linux, we now have information about the OS capabilities
// available to us.
SandboxInfo::SubmitTelemetry();
SandboxInfo sandboxInfo = SandboxInfo::Get();
Telemetry::Accumulate(Telemetry::SANDBOX_HAS_SECCOMP_BPF,
sandboxInfo.Test(SandboxInfo::kHasSeccompBPF));
Telemetry::Accumulate(Telemetry::SANDBOX_HAS_SECCOMP_TSYNC,
sandboxInfo.Test(SandboxInfo::kHasSeccompTSync));
Telemetry::Accumulate(Telemetry::SANDBOX_HAS_USER_NAMESPACES_PRIVILEGED,
sandboxInfo.Test(SandboxInfo::kHasPrivilegedUserNamespaces));
Telemetry::Accumulate(Telemetry::SANDBOX_HAS_USER_NAMESPACES,
sandboxInfo.Test(SandboxInfo::kHasUserNamespaces));
Telemetry::Accumulate(Telemetry::SANDBOX_CONTENT_ENABLED,
sandboxInfo.Test(SandboxInfo::kEnabledForContent));
Telemetry::Accumulate(Telemetry::SANDBOX_MEDIA_ENABLED,
sandboxInfo.Test(SandboxInfo::kEnabledForMedia));
#if defined(MOZ_CRASHREPORTER)
SandboxInfo::Get().AnnotateCrashReport();
nsAutoCString flagsString;
flagsString.AppendInt(sandboxInfo.AsInteger());
CrashReporter::AnnotateCrashReport(
NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString);
#endif /* MOZ_CRASHREPORTER */
#endif /* MOZ_SANDBOX && XP_LINUX && !MOZ_WIDGET_GONK */