Bug 1769807 - Ensure Win32k state initialized before content launch. r=nalexander, a=RyanVM
Win32k Lockdown state must be initialized on the main thread, but currently
a process launcher may be the first thing to read it on the IPC Thread
Initializing Win32k Lockdown state also relies on the gfxPlatform being
initialized, but that also isn't explicit anywhere.
This patch ensures both things are true: Always ensure that Win32k State is
initialized before queuing a process launch to the IPC Thread, and always
ensure that gfxPlatform is initialized before attempting to read the
gfx state.
Differential Revision:
https://phabricator.services.mozilla.com/D146821
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -588,16 +588,20 @@ void GeckoChildProcessHost::PrepareLaunc
SandboxLaunchPrepare(mProcessType, mLaunchOptions.get());
#endif
#ifdef XP_WIN
# if defined(MOZ_SANDBOX)
// We need to get the pref here as the process is launched off main thread.
if (mProcessType == GeckoProcessType_Content) {
+ // Win32k Lockdown state must be initialized on the main thread.
+ // This is our last chance to do it before it is read on the IPC Launch
+ // thread
+ GetWin32kLockdownState();
mSandboxLevel = GetEffectiveContentSandboxLevel();
mEnableSandboxLogging =
Preferences::GetBool("security.sandbox.logging.enabled");
// We currently have to whitelist certain paths for tests to work in some
// development configurations.
nsAutoString readPaths;
nsresult rv = Preferences::GetString(
--- a/toolkit/components/backgroundtasks/tests/browser/browser_xpcom_graph_wait.js
+++ b/toolkit/components/backgroundtasks/tests/browser/browser_xpcom_graph_wait.js
@@ -96,16 +96,28 @@ const backgroundtaskPhases = {
},
{
name: "@mozilla.org/widget/appshell/win;1",
condition: WIN,
},
"@mozilla.org/xpcom/debug;1",
"@mozilla.org/xre/app-info;1",
"@mozilla.org/mime;1",
+ {
+ name: "@mozilla.org/gfx/info;1",
+ condition: WIN,
+ },
+ {
+ name: "@mozilla.org/image/tools;1",
+ condition: WIN,
+ },
+ {
+ name: "@mozilla.org/gfx/screenmanager;1",
+ condition: WIN,
+ },
],
},
},
AfterFindRunBackgroundTask: {
allowlist: {
components: [],
modules: [
// We have a profile marker for this, even though it failed to load!
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -693,17 +693,17 @@ void EnsureWin32kInitialized();
}
nsIXULRuntime::ContentWin32kLockdownState GetLiveWin32kLockdownState() {
#ifdef XP_WIN
// HasUserValue The Pref functions can only be called on main thread
MOZ_ASSERT(NS_IsMainThread());
mozilla::EnsureWin32kInitialized();
- gfx::gfxVars::Initialize();
+ gfxPlatform::GetPlatform();
if (gSafeMode) {
return nsIXULRuntime::ContentWin32kLockdownState::DisabledBySafeMode;
}
if (EnvHasValue("MOZ_ENABLE_WIN32K")) {
return nsIXULRuntime::ContentWin32kLockdownState::DisabledByEnvVar;
}