зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset c63f50d02eac (bug 1756518) for bp-hybrid bustage on SocketProcessHost.cpp. CLOSED TREE
This commit is contained in:
Родитель
2a6ac4b2a8
Коммит
eceb974192
|
@ -2766,16 +2766,6 @@ BrowserGlue.prototype = {
|
|||
},
|
||||
},
|
||||
|
||||
{
|
||||
condition: AppConstants.platform == "win",
|
||||
task: () => {
|
||||
Services.obs.notifyObservers(
|
||||
null,
|
||||
"unblock-untrusted-modules-thread"
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
// WebDriver components (Remote Agent and Marionette) need to be
|
||||
// initialized as very last step.
|
||||
{
|
||||
|
|
|
@ -676,8 +676,7 @@ mozilla::ipc::IPCResult ContentChild::RecvSetXPCOMProcessAttributes(
|
|||
FullLookAndFeel&& aLookAndFeelData, dom::SystemFontList&& aFontList,
|
||||
Maybe<SharedMemoryHandle>&& aSharedUASheetHandle,
|
||||
const uintptr_t& aSharedUASheetAddress,
|
||||
nsTArray<SharedMemoryHandle>&& aSharedFontListBlocks,
|
||||
const bool& aIsReadyForBackgroundProcessing) {
|
||||
nsTArray<SharedMemoryHandle>&& aSharedFontListBlocks) {
|
||||
if (!sShutdownCanary) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
@ -692,8 +691,7 @@ mozilla::ipc::IPCResult ContentChild::RecvSetXPCOMProcessAttributes(
|
|||
|
||||
gfx::gfxVars::SetValuesForInitialize(aXPCOMInit.gfxNonDefaultVarUpdates());
|
||||
InitSharedUASheets(std::move(aSharedUASheetHandle), aSharedUASheetAddress);
|
||||
InitXPCOM(std::move(aXPCOMInit), aInitialData,
|
||||
aIsReadyForBackgroundProcessing);
|
||||
InitXPCOM(std::move(aXPCOMInit), aInitialData);
|
||||
InitGraphicsDeviceData(aXPCOMInit.contentDeviceData());
|
||||
|
||||
return IPC_OK();
|
||||
|
@ -1325,8 +1323,7 @@ void ContentChild::InitSharedUASheets(Maybe<SharedMemoryHandle>&& aHandle,
|
|||
|
||||
void ContentChild::InitXPCOM(
|
||||
XPCOMInitData&& aXPCOMInit,
|
||||
const mozilla::dom::ipc::StructuredCloneData& aInitialData,
|
||||
bool aIsReadyForBackgroundProcessing) {
|
||||
const mozilla::dom::ipc::StructuredCloneData& aInitialData) {
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
// LookAndFeel::NativeInit takes a long time to run on Linux, here we schedule
|
||||
// it as soon as possible after BackgroundChild::Startup to give
|
||||
|
@ -1339,7 +1336,7 @@ void ContentChild::InitXPCOM(
|
|||
// DLL services untrusted modules processing depends on
|
||||
// BackgroundChild::Startup having been called
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
dllSvc->StartUntrustedModulesProcessor(aIsReadyForBackgroundProcessing);
|
||||
dllSvc->StartUntrustedModulesProcessor();
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
PBackgroundChild* actorChild = BackgroundChild::GetOrCreateForCurrentThread();
|
||||
|
@ -1466,14 +1463,6 @@ mozilla::ipc::IPCResult ContentChild::RecvGetUntrustedModulesData(
|
|||
[aResolver](nsresult aReason) { aResolver(Nothing()); });
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvUnblockUntrustedModulesThread() {
|
||||
if (nsCOMPtr<nsIObserverService> obs =
|
||||
mozilla::services::GetObserverService()) {
|
||||
obs->NotifyObservers(nullptr, "unblock-untrusted-modules-thread", nullptr);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
PCycleCollectWithLogsChild* ContentChild::AllocPCycleCollectWithLogsChild(
|
||||
|
|
|
@ -124,8 +124,7 @@ class ContentChild final : public PContentChild,
|
|||
bool aIsForBrowser);
|
||||
|
||||
void InitXPCOM(XPCOMInitData&& aXPCOMInit,
|
||||
const mozilla::dom::ipc::StructuredCloneData& aInitialData,
|
||||
bool aIsReadyForBackgroundProcessing);
|
||||
const mozilla::dom::ipc::StructuredCloneData& aInitialData);
|
||||
|
||||
void InitSharedUASheets(Maybe<base::SharedMemoryHandle>&& aHandle,
|
||||
uintptr_t aAddress);
|
||||
|
@ -539,7 +538,6 @@ class ContentChild final : public PContentChild,
|
|||
#if defined(XP_WIN)
|
||||
mozilla::ipc::IPCResult RecvGetUntrustedModulesData(
|
||||
GetUntrustedModulesDataResolver&& aResolver);
|
||||
mozilla::ipc::IPCResult RecvUnblockUntrustedModulesThread();
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetXPCOMProcessAttributes(
|
||||
|
@ -547,8 +545,7 @@ class ContentChild final : public PContentChild,
|
|||
FullLookAndFeel&& aLookAndFeelData, SystemFontList&& aFontList,
|
||||
Maybe<base::SharedMemoryHandle>&& aSharedUASheetHandle,
|
||||
const uintptr_t& aSharedUASheetAddress,
|
||||
nsTArray<base::SharedMemoryHandle>&& aSharedFontListBlocks,
|
||||
const bool& aIsReadyForBackgroundProcessing);
|
||||
nsTArray<base::SharedMemoryHandle>&& aSharedFontListBlocks);
|
||||
|
||||
mozilla::ipc::IPCResult RecvProvideAnonymousTemporaryFile(
|
||||
const uint64_t& aID, const FileDescOrError& aFD);
|
||||
|
|
|
@ -2990,16 +2990,9 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
|
|||
sharedUASheetAddress = 0;
|
||||
}
|
||||
|
||||
bool isReadyForBackgroundProcessing = false;
|
||||
#if defined(XP_WIN)
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
isReadyForBackgroundProcessing = dllSvc->IsReadyForBackgroundProcessing();
|
||||
#endif
|
||||
|
||||
Unused << SendSetXPCOMProcessAttributes(
|
||||
xpcomInit, initialData, lnf, fontList, std::move(sharedUASheetHandle),
|
||||
sharedUASheetAddress, std::move(sharedFontListBlocks),
|
||||
isReadyForBackgroundProcessing);
|
||||
sharedUASheetAddress, std::move(sharedFontListBlocks));
|
||||
|
||||
ipc::WritableSharedMap* sharedData =
|
||||
nsFrameMessageManager::sParentProcessManager->SharedData();
|
||||
|
|
|
@ -580,13 +580,6 @@ child:
|
|||
* to pull data from content processes.
|
||||
*/
|
||||
async GetUntrustedModulesData() returns (UntrustedModulesData? data);
|
||||
|
||||
/**
|
||||
* This method is used to notifty 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)
|
||||
|
||||
/**
|
||||
|
@ -757,8 +750,7 @@ child:
|
|||
SystemFontList systemFontList,
|
||||
SharedMemoryHandle? sharedUASheetHandle,
|
||||
uintptr_t sharedUASheetAddress,
|
||||
SharedMemoryHandle[] sharedFontListBlocks,
|
||||
bool aIsStartingUp);
|
||||
SharedMemoryHandle[] sharedFontListBlocks);
|
||||
|
||||
// Notify child that last-pb-context-exited notification was observed
|
||||
async LastPrivateDocShellDestroyed();
|
||||
|
|
|
@ -38,8 +38,7 @@ protocol PRDD
|
|||
parent:
|
||||
|
||||
async Init(GfxVarUpdate[] vars, FileDescriptor? sandboxBroker,
|
||||
bool canRecordReleaseTelemetry,
|
||||
bool aIsReadyForBackgroundProcessing);
|
||||
bool canRecordReleaseTelemetry);
|
||||
|
||||
async InitProfiler(Endpoint<PProfilerChild> endpoint);
|
||||
|
||||
|
@ -62,13 +61,6 @@ parent:
|
|||
|
||||
#if defined(XP_WIN)
|
||||
async GetUntrustedModulesData() returns (UntrustedModulesData? data);
|
||||
|
||||
/**
|
||||
* This method is used to notifty 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)
|
||||
|
|
|
@ -59,14 +59,7 @@ bool RDDChild::Init() {
|
|||
|
||||
nsTArray<GfxVarUpdate> updates = gfxVars::FetchNonDefaultVars();
|
||||
|
||||
bool isReadyForBackgroundProcessing = false;
|
||||
#if defined(XP_WIN)
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
isReadyForBackgroundProcessing = dllSvc->IsReadyForBackgroundProcessing();
|
||||
#endif
|
||||
|
||||
SendInit(updates, brokerFd, Telemetry::CanRecordReleaseData(),
|
||||
isReadyForBackgroundProcessing);
|
||||
SendInit(updates, brokerFd, Telemetry::CanRecordReleaseData());
|
||||
|
||||
Unused << SendInitProfiler(ProfilerParent::CreateForProcess(OtherPid()));
|
||||
|
||||
|
|
|
@ -124,8 +124,7 @@ void CGSShutdownServerConnections();
|
|||
|
||||
mozilla::ipc::IPCResult RDDParent::RecvInit(
|
||||
nsTArray<GfxVarUpdate>&& vars, const Maybe<FileDescriptor>& aBrokerFd,
|
||||
const bool& aCanRecordReleaseTelemetry,
|
||||
const bool& aIsReadyForBackgroundProcessing) {
|
||||
const bool& aCanRecordReleaseTelemetry) {
|
||||
for (const auto& var : vars) {
|
||||
gfxVars::ApplyUpdate(var);
|
||||
}
|
||||
|
@ -152,7 +151,7 @@ mozilla::ipc::IPCResult RDDParent::RecvInit(
|
|||
#if defined(XP_WIN)
|
||||
if (aCanRecordReleaseTelemetry) {
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
dllSvc->StartUntrustedModulesProcessor(aIsReadyForBackgroundProcessing);
|
||||
dllSvc->StartUntrustedModulesProcessor();
|
||||
}
|
||||
#endif // defined(XP_WIN)
|
||||
return IPC_OK();
|
||||
|
@ -248,14 +247,6 @@ mozilla::ipc::IPCResult RDDParent::RecvGetUntrustedModulesData(
|
|||
[aResolver](nsresult aReason) { aResolver(Nothing()); });
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult RDDParent::RecvUnblockUntrustedModulesThread() {
|
||||
if (nsCOMPtr<nsIObserverService> obs =
|
||||
mozilla::services::GetObserverService()) {
|
||||
obs->NotifyObservers(nullptr, "unblock-untrusted-modules-thread", nullptr);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
mozilla::ipc::IPCResult RDDParent::RecvPreferenceUpdate(const Pref& aPref) {
|
||||
|
|
|
@ -29,8 +29,7 @@ class RDDParent final : public PRDDParent {
|
|||
|
||||
mozilla::ipc::IPCResult RecvInit(nsTArray<GfxVarUpdate>&& vars,
|
||||
const Maybe<ipc::FileDescriptor>& aBrokerFd,
|
||||
const bool& aCanRecordReleaseTelemetry,
|
||||
const bool& aIsReadyForBackgroundProcessing);
|
||||
const bool& aCanRecordReleaseTelemetry);
|
||||
mozilla::ipc::IPCResult RecvInitProfiler(
|
||||
Endpoint<PProfilerChild>&& aEndpoint);
|
||||
|
||||
|
@ -48,7 +47,6 @@ class RDDParent final : public PRDDParent {
|
|||
#if defined(XP_WIN)
|
||||
mozilla::ipc::IPCResult RecvGetUntrustedModulesData(
|
||||
GetUntrustedModulesDataResolver&& aResolver);
|
||||
mozilla::ipc::IPCResult RecvUnblockUntrustedModulesThread();
|
||||
#endif // defined(XP_WIN)
|
||||
mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& pref);
|
||||
mozilla::ipc::IPCResult RecvUpdateVar(const GfxVarUpdate& pref);
|
||||
|
|
|
@ -138,7 +138,7 @@ mozilla::ipc::IPCResult UtilityProcessChild::RecvInit(
|
|||
#if defined(XP_WIN)
|
||||
if (aCanRecordReleaseTelemetry) {
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
dllSvc->StartUntrustedModulesProcessor(false);
|
||||
dllSvc->StartUntrustedModulesProcessor();
|
||||
}
|
||||
#endif // defined(XP_WIN)
|
||||
return IPC_OK();
|
||||
|
|
|
@ -1318,7 +1318,7 @@ int XRE_XPCShellMain(int argc, char** argv, char** envp,
|
|||
|
||||
// Ensure that DLL Services are running
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
dllSvc->StartUntrustedModulesProcessor(true);
|
||||
dllSvc->StartUntrustedModulesProcessor();
|
||||
auto dllServicesDisable =
|
||||
MakeScopeExit([&dllSvc]() { dllSvc->DisableFull(); });
|
||||
|
||||
|
|
|
@ -85,9 +85,6 @@ struct SocketPorcessInitAttributes {
|
|||
bool mOffline;
|
||||
bool mConnectivity;
|
||||
bool mInitSandbox;
|
||||
#if defined(XP_WIN)
|
||||
bool mIsReadyForBackgroundProcessing;
|
||||
#endif
|
||||
FileDescriptor? mSandboxBroker;
|
||||
};
|
||||
|
||||
|
@ -225,13 +222,6 @@ child:
|
|||
|
||||
#if defined(XP_WIN)
|
||||
async GetUntrustedModulesData() returns (UntrustedModulesData? data);
|
||||
|
||||
/**
|
||||
* This method is used to notifty 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)
|
||||
|
||||
both:
|
||||
|
|
|
@ -169,6 +169,11 @@ bool SocketProcessChild::Init(base::ProcessId aParentPid,
|
|||
return false;
|
||||
}
|
||||
|
||||
#if defined(XP_WIN)
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
dllSvc->StartUntrustedModulesProcessor();
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -223,12 +228,6 @@ mozilla::ipc::IPCResult SocketProcessChild::RecvInit(
|
|||
Unused << RecvInitLinuxSandbox(aAttributes.mSandboxBroker());
|
||||
}
|
||||
|
||||
#if defined(XP_WIN)
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
dllSvc->StartUntrustedModulesProcessor(
|
||||
aAttributes.mIsReadyForBackgroundProcessing());
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -741,15 +740,6 @@ mozilla::ipc::IPCResult SocketProcessChild::RecvGetUntrustedModulesData(
|
|||
[aResolver](nsresult aReason) { aResolver(Nothing()); });
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
SocketProcessChild::RecvUnblockUntrustedModulesThread() {
|
||||
if (nsCOMPtr<nsIObserverService> obs =
|
||||
mozilla::services::GetObserverService()) {
|
||||
obs->NotifyObservers(nullptr, "unblock-untrusted-modules-thread", nullptr);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
} // namespace net
|
||||
|
|
|
@ -160,7 +160,6 @@ class SocketProcessChild final
|
|||
#if defined(XP_WIN)
|
||||
mozilla::ipc::IPCResult RecvGetUntrustedModulesData(
|
||||
GetUntrustedModulesDataResolver&& aResolver);
|
||||
mozilla::ipc::IPCResult RecvUnblockUntrustedModulesThread();
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
protected:
|
||||
|
|
|
@ -176,12 +176,6 @@ void SocketProcessHost::InitAfterConnect(bool aSucceeded) {
|
|||
|
||||
attributes.mInitSandbox() = false;
|
||||
|
||||
#if defined(XP_WIN)
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
attributes.mIsReadyForBackgroundProcessing() =
|
||||
dllSvc->IsReadyForBackgroundProcessing();
|
||||
#endif
|
||||
|
||||
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
|
||||
if (GetEffectiveSocketProcessSandboxLevel() > 0) {
|
||||
auto policy = SandboxBrokerPolicyFactory::GetSocketProcessPolicy(
|
||||
|
|
|
@ -11,13 +11,9 @@
|
|||
#include "mozilla/CmdLineAndEnvUtils.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/net/SocketProcessChild.h"
|
||||
#include "mozilla/net/SocketProcessParent.h"
|
||||
#include "mozilla/RDDChild.h"
|
||||
#include "mozilla/RDDParent.h"
|
||||
#include "mozilla/RDDProcessManager.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
@ -110,14 +106,12 @@ bool UntrustedModulesProcessor::IsSupportedProcessType() {
|
|||
}
|
||||
|
||||
/* static */
|
||||
RefPtr<UntrustedModulesProcessor> UntrustedModulesProcessor::Create(
|
||||
bool aIsReadyForBackgroundProcessing) {
|
||||
RefPtr<UntrustedModulesProcessor> UntrustedModulesProcessor::Create() {
|
||||
if (!IsSupportedProcessType()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<UntrustedModulesProcessor> result(
|
||||
new UntrustedModulesProcessor(aIsReadyForBackgroundProcessing));
|
||||
RefPtr<UntrustedModulesProcessor> result(new UntrustedModulesProcessor());
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
|
@ -125,16 +119,14 @@ NS_IMPL_ISUPPORTS(UntrustedModulesProcessor, nsIObserver)
|
|||
|
||||
static const uint32_t kThreadTimeoutMS = 120000; // 2 minutes
|
||||
|
||||
UntrustedModulesProcessor::UntrustedModulesProcessor(
|
||||
bool aIsReadyForBackgroundProcessing)
|
||||
UntrustedModulesProcessor::UntrustedModulesProcessor()
|
||||
: mThread(new LazyIdleThread(kThreadTimeoutMS, "Untrusted Modules"_ns,
|
||||
LazyIdleThread::ManualShutdown)),
|
||||
mUnprocessedMutex(
|
||||
"mozilla::UntrustedModulesProcessor::mUnprocessedMutex"),
|
||||
mModuleCacheMutex(
|
||||
"mozilla::UntrustedModulesProcessor::mModuleCacheMutex"),
|
||||
mStatus(aIsReadyForBackgroundProcessing ? Status::Allowed
|
||||
: Status::StartingUp) {
|
||||
mAllowProcessing(true) {
|
||||
AddObservers();
|
||||
}
|
||||
|
||||
|
@ -142,22 +134,17 @@ void UntrustedModulesProcessor::AddObservers() {
|
|||
nsCOMPtr<nsIObserverService> obsServ(services::GetObserverService());
|
||||
obsServ->AddObserver(this, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID, false);
|
||||
obsServ->AddObserver(this, "xpcom-shutdown-threads", false);
|
||||
obsServ->AddObserver(this, "unblock-untrusted-modules-thread", false);
|
||||
if (XRE_IsContentProcess()) {
|
||||
obsServ->AddObserver(this, "content-child-will-shutdown", false);
|
||||
}
|
||||
}
|
||||
|
||||
bool UntrustedModulesProcessor::IsReadyForBackgroundProcessing() const {
|
||||
return mStatus == Status::Allowed;
|
||||
}
|
||||
|
||||
void UntrustedModulesProcessor::Disable() {
|
||||
// Ensure that mThread cannot run at low priority anymore
|
||||
BackgroundPriorityRegion::Clear(mThread);
|
||||
|
||||
// No more background processing allowed beyond this point
|
||||
if (mStatus.exchange(Status::ShuttingDown) != Status::Allowed) {
|
||||
if (!mAllowProcessing.exchange(false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -184,37 +171,6 @@ NS_IMETHODIMP UntrustedModulesProcessor::Observe(nsISupports* aSubject,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!strcmp(aTopic, "unblock-untrusted-modules-thread")) {
|
||||
nsCOMPtr<nsIObserverService> obs(services::GetObserverService());
|
||||
obs->RemoveObserver(this, "unblock-untrusted-modules-thread");
|
||||
|
||||
mStatus.compareExchange(Status::StartingUp, Status::Allowed);
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
// If we're shutting down, stop here.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
// Propagate notification to child processes
|
||||
nsTArray<dom::ContentParent*> contentProcesses;
|
||||
dom::ContentParent::GetAll(contentProcesses);
|
||||
for (auto* proc : contentProcesses) {
|
||||
Unused << proc->SendUnblockUntrustedModulesThread();
|
||||
}
|
||||
if (auto* proc = net::SocketProcessParent::GetSingleton()) {
|
||||
Unused << proc->SendUnblockUntrustedModulesThread();
|
||||
}
|
||||
if (auto* rddMgr = RDDProcessManager::Get()) {
|
||||
if (auto* proc = rddMgr->GetRDDChild()) {
|
||||
Unused << proc->SendUnblockUntrustedModulesThread();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_ASSERT_UNREACHABLE("Not reachable");
|
||||
|
||||
return NS_OK;
|
||||
|
@ -224,7 +180,6 @@ void UntrustedModulesProcessor::RemoveObservers() {
|
|||
nsCOMPtr<nsIObserverService> obsServ(services::GetObserverService());
|
||||
obsServ->RemoveObserver(this, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID);
|
||||
obsServ->RemoveObserver(this, "xpcom-shutdown-threads");
|
||||
obsServ->RemoveObserver(this, "unblock-untrusted-modules-thread");
|
||||
if (XRE_IsContentProcess()) {
|
||||
obsServ->RemoveObserver(this, "content-child-will-shutdown");
|
||||
}
|
||||
|
@ -249,7 +204,7 @@ void UntrustedModulesProcessor::ScheduleNonEmptyQueueProcessing(
|
|||
return;
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -286,7 +241,7 @@ void UntrustedModulesProcessor::CancelScheduledProcessing(
|
|||
void UntrustedModulesProcessor::DispatchBackgroundProcessing() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -299,7 +254,7 @@ void UntrustedModulesProcessor::DispatchBackgroundProcessing() {
|
|||
|
||||
void UntrustedModulesProcessor::Enqueue(
|
||||
glue::EnhancedModuleLoadInfo&& aModLoadInfo) {
|
||||
if (mStatus == Status::ShuttingDown) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -317,7 +272,7 @@ void UntrustedModulesProcessor::Enqueue(
|
|||
}
|
||||
|
||||
void UntrustedModulesProcessor::Enqueue(ModuleLoadInfoVec&& aEvents) {
|
||||
if (mStatus == Status::ShuttingDown) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -360,7 +315,7 @@ RefPtr<ModulesTrustPromise> UntrustedModulesProcessor::GetModulesTrust(
|
|||
ModulePaths&& aModPaths, bool aRunAtNormalPriority) {
|
||||
MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return ModulesTrustPromise::CreateAndReject(
|
||||
NS_ERROR_ILLEGAL_DURING_SHUTDOWN, __func__);
|
||||
}
|
||||
|
@ -448,7 +403,7 @@ UntrustedModulesProcessor::GetProcessedDataInternalChildProcess() {
|
|||
self = std::move(self), source,
|
||||
whenProcessed = std::move(whenProcessed)]() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!self->IsReadyForBackgroundProcessing()) {
|
||||
if (!self->mAllowProcessing) {
|
||||
// We can't do any more work, just reject all the things
|
||||
whenProcessed->Then(
|
||||
GetMainThreadSerialEventTarget(), source,
|
||||
|
@ -487,13 +442,13 @@ UntrustedModulesProcessor::GetProcessedDataInternalChildProcess() {
|
|||
}
|
||||
|
||||
void UntrustedModulesProcessor::BackgroundProcessModuleLoadQueue() {
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
BackgroundPriorityRegion bgRgn;
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -547,7 +502,7 @@ void UntrustedModulesProcessor::BackgroundProcessModuleLoadQueueChildProcess() {
|
|||
self = std::move(self), source,
|
||||
whenProcessed = std::move(whenProcessed)]() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!self->IsReadyForBackgroundProcessing()) {
|
||||
if (!self->mAllowProcessing) {
|
||||
// We can't do any more work, just no-op
|
||||
whenProcessed->Then(
|
||||
GetMainThreadSerialEventTarget(), source,
|
||||
|
@ -559,7 +514,7 @@ void UntrustedModulesProcessor::BackgroundProcessModuleLoadQueueChildProcess() {
|
|||
whenProcessed->Then(
|
||||
evtTarget, source,
|
||||
[self = std::move(self)](Maybe<ModulesMapResultWithLoads>&& aResult) {
|
||||
if (aResult.isNothing() || !self->IsReadyForBackgroundProcessing()) {
|
||||
if (aResult.isNothing() || !self->mAllowProcessing) {
|
||||
// Nothing to do
|
||||
return;
|
||||
}
|
||||
|
@ -610,9 +565,9 @@ UntrustedModulesProcessor::ExtractLoadingEventsToProcess(size_t aMaxLength) {
|
|||
return loadsToProcess;
|
||||
}
|
||||
|
||||
// This function contains multiple IsReadyForBackgroundProcessing() checks so
|
||||
// that we can quickly bail out at the first sign of shutdown. This may be
|
||||
// important when the current thread is running under background priority.
|
||||
// This function contains multiple |mAllowProcessing| checks so that we can
|
||||
// quickly bail out at the first sign of shutdown. This may be important when
|
||||
// the current thread is running under background priority.
|
||||
void UntrustedModulesProcessor::ProcessModuleLoadQueue() {
|
||||
AssertRunningOnLazyIdleThread();
|
||||
if (!XRE_IsParentProcess()) {
|
||||
|
@ -622,7 +577,7 @@ void UntrustedModulesProcessor::ProcessModuleLoadQueue() {
|
|||
|
||||
LoadsVec loadsToProcess =
|
||||
ExtractLoadingEventsToProcess(UntrustedModulesData::kMaxEvents);
|
||||
if (!IsReadyForBackgroundProcessing() || loadsToProcess.empty()) {
|
||||
if (!mAllowProcessing || loadsToProcess.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -640,7 +595,7 @@ void UntrustedModulesProcessor::ProcessModuleLoadQueue() {
|
|||
uint32_t trustTestFailures = 0;
|
||||
|
||||
for (glue::EnhancedModuleLoadInfo& entry : loadsToProcess) {
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -653,7 +608,7 @@ void UntrustedModulesProcessor::ProcessModuleLoadQueue() {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -668,7 +623,7 @@ void UntrustedModulesProcessor::ProcessModuleLoadQueue() {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -684,14 +639,14 @@ void UntrustedModulesProcessor::ProcessModuleLoadQueue() {
|
|||
mProcessedModuleLoads.mModules.LookupOrInsert(
|
||||
event.mModule->mResolvedNtName, event.mModule);
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
Telemetry::ProcessedStack processedStack =
|
||||
stackProcessor.GetStackAndModules(backtrace);
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -706,7 +661,7 @@ void UntrustedModulesProcessor::ProcessModuleLoadQueue() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -786,7 +741,7 @@ UntrustedModulesProcessor::ProcessModuleLoadQueueChildProcess(
|
|||
return GetModulesTrustPromise::CreateAndResolve(Nothing(), __func__);
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return GetModulesTrustPromise::CreateAndReject(
|
||||
NS_ERROR_ILLEGAL_DURING_SHUTDOWN, __func__);
|
||||
}
|
||||
|
@ -795,7 +750,7 @@ UntrustedModulesProcessor::ProcessModuleLoadQueueChildProcess(
|
|||
|
||||
// Build a set of modules to be processed by the parent
|
||||
for (glue::EnhancedModuleLoadInfo& entry : loadsToProcess) {
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return GetModulesTrustPromise::CreateAndReject(
|
||||
NS_ERROR_ILLEGAL_DURING_SHUTDOWN, __func__);
|
||||
}
|
||||
|
@ -803,7 +758,7 @@ UntrustedModulesProcessor::ProcessModuleLoadQueueChildProcess(
|
|||
moduleNtPathSet.PutEntry(entry.mNtLoadInfo.mSectionName.AsString());
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return GetModulesTrustPromise::CreateAndReject(
|
||||
NS_ERROR_ILLEGAL_DURING_SHUTDOWN, __func__);
|
||||
}
|
||||
|
@ -816,7 +771,7 @@ UntrustedModulesProcessor::ProcessModuleLoadQueueChildProcess(
|
|||
|
||||
ModulePaths moduleNtPaths(std::move(moduleNtPathSet));
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return GetModulesTrustPromise::CreateAndReject(
|
||||
NS_ERROR_ILLEGAL_DURING_SHUTDOWN, __func__);
|
||||
}
|
||||
|
@ -832,7 +787,7 @@ UntrustedModulesProcessor::ProcessModuleLoadQueueChildProcess(
|
|||
RefPtr<GetModulesTrustPromise::Private> p(
|
||||
new GetModulesTrustPromise::Private(__func__));
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
p->Reject(NS_ERROR_ILLEGAL_DURING_SHUTDOWN, __func__);
|
||||
return p;
|
||||
}
|
||||
|
@ -860,7 +815,7 @@ void UntrustedModulesProcessor::CompleteProcessing(
|
|||
MOZ_ASSERT(!XRE_IsParentProcess());
|
||||
AssertRunningOnLazyIdleThread();
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -882,7 +837,7 @@ void UntrustedModulesProcessor::CompleteProcessing(
|
|||
return;
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -895,7 +850,7 @@ void UntrustedModulesProcessor::CompleteProcessing(
|
|||
|
||||
if (!modules.IsEmpty()) {
|
||||
for (auto&& item : loads) {
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -905,7 +860,7 @@ void UntrustedModulesProcessor::CompleteProcessing(
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -913,7 +868,7 @@ void UntrustedModulesProcessor::CompleteProcessing(
|
|||
std::move(item.mNtLoadInfo.mBacktrace);
|
||||
ProcessedModuleLoadEvent event(std::move(item), std::move(module));
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -924,7 +879,7 @@ void UntrustedModulesProcessor::CompleteProcessing(
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -935,7 +890,7 @@ void UntrustedModulesProcessor::CompleteProcessing(
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -954,7 +909,7 @@ void UntrustedModulesProcessor::CompleteProcessing(
|
|||
return;
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -976,7 +931,7 @@ RefPtr<ModulesTrustPromise> UntrustedModulesProcessor::GetModulesTrustInternal(
|
|||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
AssertRunningOnLazyIdleThread();
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return ModulesTrustPromise::CreateAndReject(
|
||||
NS_ERROR_ILLEGAL_DURING_SHUTDOWN, __func__);
|
||||
}
|
||||
|
@ -1010,7 +965,7 @@ RefPtr<ModulesTrustPromise> UntrustedModulesProcessor::GetModulesTrustInternal(
|
|||
|
||||
for (auto& resolvedNtPath :
|
||||
aModPaths.mModuleNtPaths.as<ModulePaths::VecType>()) {
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return ModulesTrustPromise::CreateAndReject(
|
||||
NS_ERROR_ILLEGAL_DURING_SHUTDOWN, __func__);
|
||||
}
|
||||
|
@ -1027,7 +982,7 @@ RefPtr<ModulesTrustPromise> UntrustedModulesProcessor::GetModulesTrustInternal(
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return ModulesTrustPromise::CreateAndReject(
|
||||
NS_ERROR_ILLEGAL_DURING_SHUTDOWN, __func__);
|
||||
}
|
||||
|
@ -1038,7 +993,7 @@ RefPtr<ModulesTrustPromise> UntrustedModulesProcessor::GetModulesTrustInternal(
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!IsReadyForBackgroundProcessing()) {
|
||||
if (!mAllowProcessing) {
|
||||
return ModulesTrustPromise::CreateAndReject(
|
||||
NS_ERROR_ILLEGAL_DURING_SHUTDOWN, __func__);
|
||||
}
|
||||
|
|
|
@ -37,16 +37,11 @@ using GetModulesTrustIpcPromise =
|
|||
|
||||
class UntrustedModulesProcessor final : public nsIObserver {
|
||||
public:
|
||||
static RefPtr<UntrustedModulesProcessor> Create(
|
||||
bool aIsReadyForBackgroundProcessing);
|
||||
static RefPtr<UntrustedModulesProcessor> Create();
|
||||
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
// Called to check if the parent process is ready when a child process
|
||||
// is spanwed
|
||||
bool IsReadyForBackgroundProcessing() const;
|
||||
|
||||
// Called by DLL Services to explicitly begin shutting down
|
||||
void Disable();
|
||||
|
||||
|
@ -70,7 +65,7 @@ class UntrustedModulesProcessor final : public nsIObserver {
|
|||
|
||||
private:
|
||||
~UntrustedModulesProcessor() = default;
|
||||
explicit UntrustedModulesProcessor(bool aIsReadyForBackgroundProcessing);
|
||||
UntrustedModulesProcessor();
|
||||
|
||||
static bool IsSupportedProcessType();
|
||||
|
||||
|
@ -146,10 +141,8 @@ class UntrustedModulesProcessor final : public nsIObserver {
|
|||
// This member must only be touched on mThread
|
||||
UntrustedModulesData mProcessedModuleLoads;
|
||||
|
||||
enum class Status { StartingUp, Allowed, ShuttingDown };
|
||||
|
||||
// This member may be touched by any thread
|
||||
Atomic<Status> mStatus;
|
||||
Atomic<bool> mAllowProcessing;
|
||||
|
||||
// Cache all module records, including ones trusted and ones loaded in
|
||||
// child processes, in the browser process to avoid evaluating the same
|
||||
|
|
|
@ -59,15 +59,10 @@ DllServices* DllServices::Get() {
|
|||
|
||||
DllServices::~DllServices() { DisableFull(); }
|
||||
|
||||
void DllServices::StartUntrustedModulesProcessor(bool aIsStartingUp) {
|
||||
void DllServices::StartUntrustedModulesProcessor() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!mUntrustedModulesProcessor);
|
||||
mUntrustedModulesProcessor = UntrustedModulesProcessor::Create(aIsStartingUp);
|
||||
}
|
||||
|
||||
bool DllServices::IsReadyForBackgroundProcessing() const {
|
||||
return mUntrustedModulesProcessor &&
|
||||
mUntrustedModulesProcessor->IsReadyForBackgroundProcessing();
|
||||
mUntrustedModulesProcessor = UntrustedModulesProcessor::Create();
|
||||
}
|
||||
|
||||
RefPtr<UntrustedModulesPromise> DllServices::GetUntrustedModulesData() {
|
||||
|
|
|
@ -34,8 +34,7 @@ class DllServices final : public glue::DllServices {
|
|||
static const char* kTopicDllLoadedMainThread;
|
||||
static const char* kTopicDllLoadedNonMainThread;
|
||||
|
||||
void StartUntrustedModulesProcessor(bool aIsReadyForBackgroundProcessing);
|
||||
bool IsReadyForBackgroundProcessing() const;
|
||||
void StartUntrustedModulesProcessor();
|
||||
|
||||
RefPtr<UntrustedModulesPromise> GetUntrustedModulesData();
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ BOOL CALLBACK UntrustedModulesFixture::InitialModuleLoadOnce(PINIT_ONCE, void*,
|
|||
}
|
||||
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
dllSvc->StartUntrustedModulesProcessor(true);
|
||||
dllSvc->StartUntrustedModulesProcessor();
|
||||
|
||||
for (int i = 0; i < kLoadCountAfterDllServices; ++i) {
|
||||
for (const auto& mod : kTestModules) {
|
||||
|
|
|
@ -5277,7 +5277,7 @@ nsresult XREMain::XRE_mainRun() {
|
|||
|
||||
#if defined(XP_WIN)
|
||||
RefPtr<mozilla::DllServices> dllServices(mozilla::DllServices::Get());
|
||||
dllServices->StartUntrustedModulesProcessor(false);
|
||||
dllServices->StartUntrustedModulesProcessor();
|
||||
auto dllServicesDisable =
|
||||
MakeScopeExit([&dllServices]() { dllServices->DisableFull(); });
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче