Bug 1884378 - SandboxProfiler integration within processes r=padenot,necko-reviewers,kershaw

Differential Revision: https://phabricator.services.mozilla.com/D213216
This commit is contained in:
Alexandre Lissy 2024-06-14 10:17:38 +00:00
parent 088685c4d2
commit 36d4a7d5b2
6 changed files with 34 additions and 1 deletions

View File

@ -146,6 +146,7 @@
# include "CubebUtils.h"
# include "mozilla/Sandbox.h"
# include "mozilla/SandboxInfo.h"
# include "mozilla/SandboxProfilerObserver.h"
# elif defined(XP_MACOSX)
# include <CoreGraphics/CGError.h>
# include "mozilla/Sandbox.h"
@ -1709,6 +1710,7 @@ mozilla::ipc::IPCResult ContentChild::RecvSetProcessSandbox(
}
if (sandboxEnabled) {
RegisterProfilerObserversForSandboxProfiler();
sandboxEnabled = SetContentProcessSandbox(
ContentProcessSandboxParams::ForThisProcess(aBroker));
}
@ -2151,6 +2153,10 @@ mozilla::ipc::IPCResult ContentChild::RecvSetTRRMode(
}
void ContentChild::ActorDestroy(ActorDestroyReason why) {
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
DestroySandboxProfiler();
#endif
if (mForceKillTimer) {
mForceKillTimer->Cancel();
mForceKillTimer = nullptr;

View File

@ -12,7 +12,10 @@
#include "GeckoProfiler.h"
#ifdef XP_LINUX
# include "dlfcn.h"
#endif
# if defined(MOZ_SANDBOX)
# include "mozilla/Sandbox.h"
# endif // defined(MOZ_SANDBOX)
#endif // defined (XP_LINUX)
#include "gmp-video-decode.h"
#include "gmp-video-encode.h"
#include "GMPContentChild.h"
@ -567,6 +570,10 @@ MessageLoop* GMPChild::GMPMessageLoop() { return mGMPMessageLoop; }
void GMPChild::ActorDestroy(ActorDestroyReason aWhy) {
GMP_CHILD_LOG_DEBUG("%s reason=%d", __FUNCTION__, aWhy);
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
DestroySandboxProfiler();
#endif
for (uint32_t i = mGMPContentChildren.Length(); i > 0; i--) {
MOZ_ASSERT_IF(aWhy == NormalShutdown,
!mGMPContentChildren[i - 1]->IsUsed());

View File

@ -20,6 +20,7 @@
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
# include "mozilla/Sandbox.h"
# include "mozilla/SandboxInfo.h"
# include "mozilla/SandboxProfilerObserver.h"
#endif
#include <string>
@ -179,6 +180,7 @@ class LinuxSandboxStarter : public mozilla::gmp::SandboxStarter {
return nullptr;
}
bool Start(const char* aLibPath) override {
RegisterProfilerObserversForSandboxProfiler();
mozilla::SetMediaPluginSandbox(aLibPath);
return true;
}

View File

@ -32,6 +32,7 @@
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
# include "mozilla/Sandbox.h"
# include "mozilla/SandboxProfilerObserver.h"
#endif
#include "ChildProfilerController.h"
@ -149,6 +150,7 @@ mozilla::ipc::IPCResult RDDParent::RecvInit(
if (aBrokerFd.isSome()) {
fd = aBrokerFd.value().ClonePlatformHandle().release();
}
RegisterProfilerObserversForSandboxProfiler();
SetRemoteDataDecoderSandbox(fd);
# endif // XP_MACOSX/XP_LINUX
#endif // MOZ_SANDBOX
@ -288,6 +290,10 @@ mozilla::ipc::IPCResult RDDParent::RecvTestTelemetryProbes() {
}
void RDDParent::ActorDestroy(ActorDestroyReason aWhy) {
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
DestroySandboxProfiler();
#endif
if (AbnormalShutdown == aWhy) {
NS_WARNING("Shutting down RDD process early due to a crash!");
Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT, "rdd"_ns, 1);

View File

@ -19,6 +19,7 @@
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
# include "mozilla/Sandbox.h"
# include "mozilla/SandboxProfilerObserver.h"
#endif
#if defined(XP_OPENBSD) && defined(MOZ_SANDBOX)
@ -180,6 +181,7 @@ mozilla::ipc::IPCResult UtilityProcessChild::RecvInit(
fd = aBrokerFd.value().ClonePlatformHandle().release();
}
RegisterProfilerObserversForSandboxProfiler();
SetUtilitySandbox(fd, mSandbox);
# endif // XP_MACOSX/XP_LINUX
@ -348,6 +350,10 @@ UtilityProcessChild::RecvUnblockUntrustedModulesThread() {
#endif // defined(XP_WIN)
void UtilityProcessChild::ActorDestroy(ActorDestroyReason aWhy) {
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
DestroySandboxProfiler();
#endif
if (AbnormalShutdown == aWhy) {
NS_WARNING("Shutting down Utility process early due to a crash!");
ipc::ProcessChild::QuickExit();

View File

@ -60,6 +60,7 @@
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
# include "mozilla/Sandbox.h"
# include "mozilla/SandboxProfilerObserver.h"
#endif
#include "ChildProfilerController.h"
@ -225,6 +226,10 @@ void SocketProcessChild::ActorDestroy(ActorDestroyReason aWhy) {
mShuttingDown = true;
}
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
DestroySandboxProfiler();
#endif
if (AbnormalShutdown == aWhy) {
NS_WARNING("Shutting down Socket process early due to a crash!");
ProcessChild::QuickExit();
@ -339,6 +344,7 @@ mozilla::ipc::IPCResult SocketProcessChild::RecvInitLinuxSandbox(
if (aBrokerFd.isSome()) {
fd = aBrokerFd.value().ClonePlatformHandle().release();
}
RegisterProfilerObserversForSandboxProfiler();
SetSocketProcessSandbox(fd);
#endif // XP_LINUX && MOZ_SANDBOX
return IPC_OK();