merge in mnc-dr1.5-release history after reset to mnc-dr1.5-dev
diff --git a/debuggerd/tombstone.cpp b/debuggerd/tombstone.cpp
index aeffc66..b0ad274 100644
--- a/debuggerd/tombstone.cpp
+++ b/debuggerd/tombstone.cpp
@@ -788,8 +788,21 @@
   log.current_tid = tid;
   log.crashed_tid = tid;
 
+  if ((mkdir(TOMBSTONE_DIR, 0755) == -1) && (errno != EEXIST)) {
+    _LOG(&log, logtype::ERROR, "failed to create %s: %s\n", TOMBSTONE_DIR, strerror(errno));
+  }
+
+  if (chown(TOMBSTONE_DIR, AID_SYSTEM, AID_SYSTEM) == -1) {
+    _LOG(&log, logtype::ERROR, "failed to change ownership of %s: %s\n", TOMBSTONE_DIR, strerror(errno));
+  }
+
   int fd = -1;
-  char* path = find_and_open_tombstone(&fd);
+  char* path = NULL;
+  if (selinux_android_restorecon(TOMBSTONE_DIR, 0) == 0) {
+    path = find_and_open_tombstone(&fd);
+  } else {
+    _LOG(&log, logtype::ERROR, "Failed to restore security context, not writing tombstone.\n");
+  }
 
   if (fd < 0) {
     _LOG(&log, logtype::ERROR, "Skipping tombstone write, nothing to do.\n");