Bug 805173 - Enable HeapEnableTerminationOnCorruption for chrome processes on Windows. draft
authorAlex Gaynor <agaynor@mozilla.com>
Fri, 31 Mar 2017 16:15:56 -0400
changeset 554515 637d03fba7b3d8353c5aefbf5af8fca3dca33231
parent 554422 13f5ae940c4eb099b987484885f9edf71ed0380b
child 622369 1726f6b58a8e4a4d2d41345923bd6f89f02b5210
push id51969
push userbmo:agaynor@mozilla.com
push dateFri, 31 Mar 2017 20:26:19 +0000
bugs805173
milestone55.0a1
Bug 805173 - Enable HeapEnableTerminationOnCorruption for chrome processes on Windows. This is an exploit mitigation which causes the Windows system allocator to abort in the event it is in a corrupted state, rather than attempt to proceed in a potentially exploitable state. Because we use jemalloc, this only affects system libraries or plugins which still use the system allocator. The has been enabled on our content processes for a while without incident. r=mhowell,tjr MozReview-Commit-ID: 5ctXugtbI1A
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -3708,16 +3708,23 @@ XREMain::XRE_mainStartup(bool* aExitFlag
     const char* releaseChannel = NS_STRINGIFY(MOZ_UPDATE_CHANNEL);
     if (strcmp(releaseChannel, "nightly") == 0 ||
         strcmp(releaseChannel, "default") == 0) {
       mozilla::Telemetry::InitIOReporting(gAppData->xreDirectory);
     }
   }
 #endif /* DEBUG */
 
+#if defined(XP_WIN)
+  // Enable the HeapEnableTerminationOnCorruption exploit mitigation. We ignore
+  // the return code because it always returns success, although it has no
+  // effect on Windows older than XP SP3.
+  HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
+#endif /* XP_WIN */
+
 #if defined(MOZ_WIDGET_GTK) || defined(MOZ_ENABLE_XREMOTE)
   // Stash DESKTOP_STARTUP_ID in malloc'ed memory because gtk_init will clear it.
 #define HAVE_DESKTOP_STARTUP_ID
   const char* desktopStartupIDEnv = PR_GetEnv("DESKTOP_STARTUP_ID");
   if (desktopStartupIDEnv) {
     mDesktopStartupID.Assign(desktopStartupIDEnv);
   }
 #endif