Bug 1826784 - Collect Third-Party Modules informations for Utility processes r=gstoll
Differential Revision: https://phabricator.services.mozilla.com/D174898
This commit is contained in:
@@ -30,6 +30,12 @@ using mozilla::Telemetry::KeyedScalarAction from "mozilla/TelemetryComms.h";
|
||||
using mozilla::Telemetry::ChildEventData from "mozilla/TelemetryComms.h";
|
||||
using mozilla::Telemetry::DiscardedData from "mozilla/TelemetryComms.h";
|
||||
|
||||
#if defined(XP_WIN)
|
||||
[MoveOnly] using mozilla::UntrustedModulesData from "mozilla/UntrustedModulesData.h";
|
||||
[MoveOnly] using mozilla::ModulePaths from "mozilla/UntrustedModulesData.h";
|
||||
[MoveOnly] using mozilla::ModulesMapResult from "mozilla/UntrustedModulesData.h";
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace ipc {
|
||||
@@ -50,6 +56,11 @@ parent:
|
||||
// https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/ipc.html
|
||||
async FOGData(ByteBuf buf);
|
||||
|
||||
#if defined(XP_WIN)
|
||||
async GetModulesTrust(ModulePaths aModPaths, bool aRunAtNormalPriority)
|
||||
returns (ModulesMapResult? modMapResult);
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
// Messages for sending telemetry to parent process.
|
||||
async AccumulateChildHistograms(HistogramAccumulation[] accumulations);
|
||||
async AccumulateChildKeyedHistograms(KeyedHistogramAccumulation[] accumulations);
|
||||
@@ -61,7 +72,7 @@ parent:
|
||||
async InitCompleted();
|
||||
|
||||
child:
|
||||
async Init(FileDescriptor? sandboxBroker, bool canRecordReleaseTelemetry);
|
||||
async Init(FileDescriptor? sandboxBroker, bool canRecordReleaseTelemetry, bool aIsReadyForBackgroundProcessing);
|
||||
|
||||
async InitProfiler(Endpoint<PProfilerChild> endpoint);
|
||||
|
||||
@@ -91,7 +102,16 @@ child:
|
||||
|
||||
#if defined(XP_WIN)
|
||||
async StartWindowsUtilsService(Endpoint<PWindowsUtilsChild> aEndpoint);
|
||||
#endif
|
||||
|
||||
async GetUntrustedModulesData() returns (UntrustedModulesData? data);
|
||||
|
||||
/**
|
||||
* This method is used to notify a child process to start
|
||||
* processing module loading events in UntrustedModulesProcessor.
|
||||
* This should be called when the parent process has gone idle.
|
||||
*/
|
||||
async UnblockUntrustedModulesThread();
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
#if defined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS)
|
||||
async InitSandboxTesting(Endpoint<PSandboxTestingChild> aEndpoint);
|
||||
|
||||
@@ -156,7 +156,8 @@ void CGSShutdownServerConnections();
|
||||
|
||||
mozilla::ipc::IPCResult UtilityProcessChild::RecvInit(
|
||||
const Maybe<FileDescriptor>& aBrokerFd,
|
||||
const bool& aCanRecordReleaseTelemetry) {
|
||||
const bool& aCanRecordReleaseTelemetry,
|
||||
const bool& aIsReadyForBackgroundProcessing) {
|
||||
// Do this now (before closing WindowServer on macOS) to avoid risking
|
||||
// blocking in GetCurrentProcess() called on that platform
|
||||
mozilla::ipc::SetThisProcessName("Utility Process");
|
||||
@@ -182,7 +183,7 @@ mozilla::ipc::IPCResult UtilityProcessChild::RecvInit(
|
||||
#if defined(XP_WIN)
|
||||
if (aCanRecordReleaseTelemetry) {
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
dllSvc->StartUntrustedModulesProcessor(false);
|
||||
dllSvc->StartUntrustedModulesProcessor(aIsReadyForBackgroundProcessing);
|
||||
}
|
||||
#endif // defined(XP_WIN)
|
||||
return IPC_OK();
|
||||
@@ -272,7 +273,7 @@ mozilla::ipc::IPCResult UtilityProcessChild::RecvStartJSOracleService(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
#if defined(XP_WIN)
|
||||
mozilla::ipc::IPCResult UtilityProcessChild::RecvStartWindowsUtilsService(
|
||||
Endpoint<dom::PWindowsUtilsChild>&& aEndpoint) {
|
||||
mWindowsUtilsInstance = new dom::WindowsUtilsChild();
|
||||
@@ -284,7 +285,28 @@ mozilla::ipc::IPCResult UtilityProcessChild::RecvStartWindowsUtilsService(
|
||||
MOZ_ASSERT(ok);
|
||||
return IPC_OK();
|
||||
}
|
||||
#endif
|
||||
|
||||
mozilla::ipc::IPCResult UtilityProcessChild::RecvGetUntrustedModulesData(
|
||||
GetUntrustedModulesDataResolver&& aResolver) {
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
dllSvc->GetUntrustedModulesData()->Then(
|
||||
GetMainThreadSerialEventTarget(), __func__,
|
||||
[aResolver](Maybe<UntrustedModulesData>&& aData) {
|
||||
aResolver(std::move(aData));
|
||||
},
|
||||
[aResolver](nsresult aReason) { aResolver(Nothing()); });
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
UtilityProcessChild::RecvUnblockUntrustedModulesThread() {
|
||||
if (nsCOMPtr<nsIObserverService> obs =
|
||||
mozilla::services::GetObserverService()) {
|
||||
obs->NotifyObservers(nullptr, "unblock-untrusted-modules-thread", nullptr);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
void UtilityProcessChild::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
if (AbnormalShutdown == aWhy) {
|
||||
|
||||
@@ -38,7 +38,8 @@ class UtilityProcessChild final : public PUtilityProcessChild {
|
||||
const nsCString& aParentBuildID, uint64_t aSandboxingKind);
|
||||
|
||||
mozilla::ipc::IPCResult RecvInit(const Maybe<ipc::FileDescriptor>& aBrokerFd,
|
||||
const bool& aCanRecordReleaseTelemetry);
|
||||
const bool& aCanRecordReleaseTelemetry,
|
||||
const bool& aIsReadyForBackgroundProcessing);
|
||||
mozilla::ipc::IPCResult RecvInitProfiler(
|
||||
Endpoint<PProfilerChild>&& aEndpoint);
|
||||
|
||||
@@ -63,10 +64,14 @@ class UtilityProcessChild final : public PUtilityProcessChild {
|
||||
mozilla::ipc::IPCResult RecvStartJSOracleService(
|
||||
Endpoint<dom::PJSOracleChild>&& aEndpoint);
|
||||
|
||||
#ifdef XP_WIN
|
||||
#if defined(XP_WIN)
|
||||
mozilla::ipc::IPCResult RecvStartWindowsUtilsService(
|
||||
Endpoint<PWindowsUtilsChild>&& aEndpoint);
|
||||
#endif
|
||||
|
||||
mozilla::ipc::IPCResult RecvGetUntrustedModulesData(
|
||||
GetUntrustedModulesDataResolver&& aResolver);
|
||||
mozilla::ipc::IPCResult RecvUnblockUntrustedModulesThread();
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
AsyncBlockers& AsyncShutdownService() { return mShutdownBlockers; }
|
||||
|
||||
|
||||
@@ -237,7 +237,14 @@ void UtilityProcessHost::InitAfterConnect(bool aSucceeded) {
|
||||
}
|
||||
#endif // XP_LINUX && MOZ_SANDBOX
|
||||
|
||||
Unused << GetActor()->SendInit(brokerFd, Telemetry::CanRecordReleaseData());
|
||||
bool isReadyForBackgroundProcessing = false;
|
||||
#if defined(XP_WIN)
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
isReadyForBackgroundProcessing = dllSvc->IsReadyForBackgroundProcessing();
|
||||
#endif
|
||||
|
||||
Unused << GetActor()->SendInit(brokerFd, Telemetry::CanRecordReleaseData(),
|
||||
isReadyForBackgroundProcessing);
|
||||
|
||||
Unused << GetActor()->SendInitProfiler(
|
||||
ProfilerParent::CreateForProcess(GetActor()->OtherPid()));
|
||||
|
||||
@@ -65,6 +65,22 @@ mozilla::ipc::IPCResult UtilityProcessParent::RecvFOGData(ByteBuf&& aBuf) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
#if defined(XP_WIN)
|
||||
mozilla::ipc::IPCResult UtilityProcessParent::RecvGetModulesTrust(
|
||||
ModulePaths&& aModPaths, bool aRunAtNormalPriority,
|
||||
GetModulesTrustResolver&& aResolver) {
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
dllSvc->GetModulesTrust(std::move(aModPaths), aRunAtNormalPriority)
|
||||
->Then(
|
||||
GetMainThreadSerialEventTarget(), __func__,
|
||||
[aResolver](ModulesMapResult&& aResult) {
|
||||
aResolver(Some(ModulesMapResult(std::move(aResult))));
|
||||
},
|
||||
[aResolver](nsresult aRv) { aResolver(Nothing()); });
|
||||
return IPC_OK();
|
||||
}
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
mozilla::ipc::IPCResult UtilityProcessParent::RecvAccumulateChildHistograms(
|
||||
nsTArray<HistogramAccumulation>&& aAccumulations) {
|
||||
TelemetryIPC::AccumulateChildHistograms(Telemetry::ProcessID::Utility,
|
||||
|
||||
@@ -38,6 +38,12 @@ class UtilityProcessParent final
|
||||
|
||||
mozilla::ipc::IPCResult RecvFOGData(ByteBuf&& aBuf);
|
||||
|
||||
#if defined(XP_WIN)
|
||||
mozilla::ipc::IPCResult RecvGetModulesTrust(
|
||||
ModulePaths&& aModPaths, bool aRunAtNormalPriority,
|
||||
GetModulesTrustResolver&& aResolver);
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
mozilla::ipc::IPCResult RecvAccumulateChildHistograms(
|
||||
nsTArray<HistogramAccumulation>&& aAccumulations);
|
||||
mozilla::ipc::IPCResult RecvAccumulateChildKeyedHistograms(
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "mozilla/net/SocketProcessParent.h"
|
||||
#include "mozilla/ipc/UtilityProcessParent.h"
|
||||
#include "mozilla/ipc/UtilityProcessManager.h"
|
||||
#include "mozilla/RDDChild.h"
|
||||
#include "mozilla/RDDProcessManager.h"
|
||||
#include "mozilla/WinDllServices.h"
|
||||
@@ -140,6 +142,14 @@ MultiGetUntrustedModulesData::GetUntrustedModuleLoadEvents() {
|
||||
}
|
||||
}
|
||||
|
||||
if (RefPtr<ipc::UtilityProcessManager> utilityManager =
|
||||
ipc::UtilityProcessManager::GetIfExists()) {
|
||||
for (RefPtr<ipc::UtilityProcessParent>& parent :
|
||||
utilityManager->GetAllProcessesProcessParent()) {
|
||||
AddPending(parent->SendGetUntrustedModulesData());
|
||||
}
|
||||
}
|
||||
|
||||
return mPromise;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/net/SocketProcessChild.h"
|
||||
#include "mozilla/net/SocketProcessParent.h"
|
||||
#include "mozilla/ipc/UtilityProcessParent.h"
|
||||
#include "mozilla/ipc/UtilityProcessChild.h"
|
||||
#include "mozilla/RDDChild.h"
|
||||
#include "mozilla/RDDParent.h"
|
||||
#include "mozilla/RDDProcessManager.h"
|
||||
@@ -78,9 +80,10 @@ bool UntrustedModulesProcessor::IsSupportedProcessType() {
|
||||
case GeckoProcessType_Socket:
|
||||
return Telemetry::CanRecordReleaseData();
|
||||
case GeckoProcessType_RDD:
|
||||
// For RDD process, we check the telemetry settings in RDDChild::Init()
|
||||
// running in the browser process because CanRecordReleaseData() always
|
||||
// returns false here.
|
||||
case GeckoProcessType_Utility:
|
||||
// For RDD and Utility process, we check the telemetry settings in
|
||||
// RDDChild::Init() / UtilityProcessChild::Init() running in the browser
|
||||
// process because CanRecordReleaseData() always returns false here.
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -751,6 +754,11 @@ UntrustedModulesProcessor::SendGetModulesTrust(ModulePaths&& aModules,
|
||||
net::SocketProcessChild::GetSingleton(), std::move(aModules),
|
||||
runNormal);
|
||||
}
|
||||
case GeckoProcessType_Utility: {
|
||||
return ::mozilla::SendGetModulesTrust(
|
||||
ipc::UtilityProcessChild::GetSingleton().get(), std::move(aModules),
|
||||
runNormal);
|
||||
}
|
||||
default: {
|
||||
MOZ_ASSERT_UNREACHABLE("Unsupported process type");
|
||||
return GetModulesTrustIpcPromise::CreateAndReject(
|
||||
|
||||
Reference in New Issue
Block a user