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
Родитель 088685c4d2
Коммит 36d4a7d5b2
6 изменённых файлов: 34 добавлений и 1 удалений

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

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

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

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

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

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

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

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

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

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

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

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