Bug 1769807 - Ensure Win32k state initialized before content launch. r=nalexander, a=RyanVM FIREFOX_RELEASE_101_BASE
authorChris Martin <cmartin@mozilla.com>
Fri, 20 May 2022 20:55:05 +0000
changeset 686417 62b172f7d5f0ea07b5c4d9e9f124b384d69a28a8
parent 686416 5208d4422e6778297f519364b838bfd8770313c8
child 686418 b7427814368cfbd276f3248ca16dcccb0c19bda2
push id16688
push userryanvm@gmail.com
push dateMon, 23 May 2022 11:48:29 +0000
treeherdermozilla-beta@62b172f7d5f0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander, RyanVM
bugs1769807
milestone101.0
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
ipc/glue/GeckoChildProcessHost.cpp
toolkit/components/backgroundtasks/tests/browser/browser_xpcom_graph_wait.js
toolkit/xre/nsAppRunner.cpp
--- 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;
   }