Bug 1236108: Add Windows sandbox policy for exception-context crash report annotations; r?bobowen draft
authorAaron Klotz <aklotz@mozilla.com>
Sat, 27 Feb 2016 17:00:42 -0700
changeset 336149 915a44b1955190f38206f54499d8287c6939f0a6
parent 336148 adef94acc05dab68e090710d75f558b6d069bb41
child 336150 2187cc1b1c163ddabc72bd71dbc18072a6304b34
push id11995
push useraklotz@mozilla.com
push dateWed, 02 Mar 2016 18:49:56 +0000
reviewersbobowen
bugs1236108
milestone47.0a1
Bug 1236108: Add Windows sandbox policy for exception-context crash report annotations; r?bobowen MozReview-Commit-ID: K26UPpxqolj
security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
--- a/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
+++ b/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
@@ -6,16 +6,17 @@
 
 #include "sandboxBroker.h"
 
 #include "base/win/windows_version.h"
 #include "sandbox/win/src/sandbox.h"
 #include "sandbox/win/src/sandbox_factory.h"
 #include "sandbox/win/src/security_level.h"
 #include "mozilla/sandboxing/sandboxLogging.h"
+#include "mozilla/ArrayUtils.h"
 
 namespace mozilla
 {
 
 sandbox::BrokerServices *SandboxBroker::sBrokerService = nullptr;
 
 SandboxBroker::SandboxBroker()
 {
@@ -190,16 +191,31 @@ SandboxBroker::SetSecurityLevelForConten
 
   // The content process needs to be able to duplicate shared memory to the
   // broker process, which are Section type handles.
   result = mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES,
                             sandbox::TargetPolicy::HANDLES_DUP_BROKER,
                             L"Section");
   ret = ret && (sandbox::SBOX_ALL_OK == result);
 
+  // Add the policy for crash reporter annotations.
+  wchar_t crashDumpAnnotationPath[MAX_PATH + 1];
+  uint32_t pathLen = ::GetTempPathW(mozilla::ArrayLength(crashDumpAnnotationPath),
+                                    crashDumpAnnotationPath);
+  if (pathLen > 0 && pathLen < mozilla::ArrayLength(crashDumpAnnotationPath)) {
+    // GetTempPath path ends with \ and returns the length without the null.
+    if (swprintf_s(crashDumpAnnotationPath + pathLen,
+                   mozilla::ArrayLength(crashDumpAnnotationPath) - pathLen,
+                   L"GeckoChildCrash%u.extra", GetCurrentProcessId()) > 0) {
+      mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
+                       sandbox::TargetPolicy::FILES_ALLOW_ANY,
+                       crashDumpAnnotationPath);
+    }
+  }
+
   return ret;
 }
 #endif
 
 bool
 SandboxBroker::SetSecurityLevelForPluginProcess(int32_t aSandboxLevel)
 {
   if (!mPolicy) {