OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // For linux_syscall_support.h. This makes it safe to call embedded system | 5 // For linux_syscall_support.h. This makes it safe to call embedded system |
6 // calls when in seccomp mode. | 6 // calls when in seccomp mode. |
7 | 7 |
8 #include "components/crash/content/app/breakpad_linux.h" | 8 #include "components/crash/content/app/breakpad_linux.h" |
9 | 9 |
10 #include <fcntl.h> | 10 #include <fcntl.h> |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 bool g_is_crash_reporter_enabled = false; | 94 bool g_is_crash_reporter_enabled = false; |
95 uint64_t g_process_start_time = 0; | 95 uint64_t g_process_start_time = 0; |
96 pid_t g_pid = 0; | 96 pid_t g_pid = 0; |
97 char* g_crash_log_path = nullptr; | 97 char* g_crash_log_path = nullptr; |
98 ExceptionHandler* g_breakpad = nullptr; | 98 ExceptionHandler* g_breakpad = nullptr; |
99 | 99 |
100 #if defined(ADDRESS_SANITIZER) | 100 #if defined(ADDRESS_SANITIZER) |
101 const char* g_asan_report_str = nullptr; | 101 const char* g_asan_report_str = nullptr; |
102 #endif | 102 #endif |
103 | 103 |
| 104 bool g_use_crash_key_white_list = false; |
| 105 const char* const* g_crash_key_white_list = nullptr; |
| 106 |
104 #if defined(OS_ANDROID) | 107 #if defined(OS_ANDROID) |
105 #define G_DUMPS_SUPPRESSED_MAGIC 0x5AFECEDE | 108 #define G_DUMPS_SUPPRESSED_MAGIC 0x5AFECEDE |
106 uint32_t g_dumps_suppressed = 0; | 109 uint32_t g_dumps_suppressed = 0; |
107 char* g_process_type = nullptr; | 110 char* g_process_type = nullptr; |
108 ExceptionHandler* g_microdump = nullptr; | 111 ExceptionHandler* g_microdump = nullptr; |
109 int g_signal_code_pipe_fd = -1; | 112 int g_signal_code_pipe_fd = -1; |
110 | 113 |
111 class MicrodumpInfo { | 114 class MicrodumpInfo { |
112 public: | 115 public: |
113 MicrodumpInfo() : microdump_gpu_fingerprint_(nullptr) {} | 116 MicrodumpInfo() : microdump_gpu_fingerprint_(nullptr) {} |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. | 1094 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. |
1092 nullptr, | 1095 nullptr, |
1093 nullptr, | 1096 nullptr, |
1094 nullptr, | 1097 nullptr, |
1095 true, | 1098 true, |
1096 -1); | 1099 -1); |
1097 g_breakpad->set_crash_generation_client(new NonBrowserCrashHandler()); | 1100 g_breakpad->set_crash_generation_client(new NonBrowserCrashHandler()); |
1098 } | 1101 } |
1099 #endif // defined(OS_ANDROID) | 1102 #endif // defined(OS_ANDROID) |
1100 | 1103 |
| 1104 bool IsInWhiteList(const base::StringPiece& key) { |
| 1105 DCHECK(g_crash_key_white_list); |
| 1106 for (size_t i = 0; g_crash_key_white_list[i]; ++i) { |
| 1107 if (0 == my_strcmp(g_crash_key_white_list[i], key.data())) { |
| 1108 return true; |
| 1109 } |
| 1110 } |
| 1111 return false; |
| 1112 } |
| 1113 |
1101 void SetCrashKeyValue(const base::StringPiece& key, | 1114 void SetCrashKeyValue(const base::StringPiece& key, |
1102 const base::StringPiece& value) { | 1115 const base::StringPiece& value) { |
1103 g_crash_keys->SetKeyValue(key.data(), value.data()); | 1116 if (!g_use_crash_key_white_list || IsInWhiteList(key)) { |
| 1117 g_crash_keys->SetKeyValue(key.data(), value.data()); |
| 1118 } |
1104 } | 1119 } |
1105 | 1120 |
1106 void ClearCrashKey(const base::StringPiece& key) { | 1121 void ClearCrashKey(const base::StringPiece& key) { |
1107 g_crash_keys->RemoveKey(key.data()); | 1122 g_crash_keys->RemoveKey(key.data()); |
1108 } | 1123 } |
1109 | 1124 |
1110 // GetCrashReporterClient() cannot call any Set methods until after | 1125 // GetCrashReporterClient() cannot call any Set methods until after |
1111 // InitCrashKeys(). | 1126 // InitCrashKeys(). |
1112 void InitCrashKeys() { | 1127 void InitCrashKeys() { |
1113 g_crash_keys = new CrashKeyStorage; | 1128 g_crash_keys = new CrashKeyStorage; |
1114 GetCrashReporterClient()->RegisterCrashKeys(); | 1129 GetCrashReporterClient()->RegisterCrashKeys(); |
| 1130 g_use_crash_key_white_list = |
| 1131 GetCrashReporterClient()->UseCrashKeysWhiteList(); |
| 1132 g_crash_key_white_list = GetCrashReporterClient()->GetCrashKeyWhiteList(); |
1115 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValue, &ClearCrashKey); | 1133 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValue, &ClearCrashKey); |
1116 } | 1134 } |
1117 | 1135 |
1118 // Miscellaneous initialization functions to call after Breakpad has been | 1136 // Miscellaneous initialization functions to call after Breakpad has been |
1119 // enabled. | 1137 // enabled. |
1120 void PostEnableBreakpadInitialization() { | 1138 void PostEnableBreakpadInitialization() { |
1121 SetProcessStartTime(); | 1139 SetProcessStartTime(); |
1122 g_pid = getpid(); | 1140 g_pid = getpid(); |
1123 | 1141 |
1124 base::debug::SetDumpWithoutCrashingFunction(&DumpProcess); | 1142 base::debug::SetDumpWithoutCrashingFunction(&DumpProcess); |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 | 1916 |
1899 #if defined(OS_ANDROID) | 1917 #if defined(OS_ANDROID) |
1900 // In Android WebView, microdumps are generated conditionally (depending on the | 1918 // In Android WebView, microdumps are generated conditionally (depending on the |
1901 // cause of the crash) and can be sanitized to prevent exposing unnecessary data | 1919 // cause of the crash) and can be sanitized to prevent exposing unnecessary data |
1902 // from the embedding application. | 1920 // from the embedding application. |
1903 void InitCrashReporter(const std::string& process_type) { | 1921 void InitCrashReporter(const std::string& process_type) { |
1904 SanitizationInfo sanitization_info; | 1922 SanitizationInfo sanitization_info; |
1905 InitCrashReporter(process_type, sanitization_info); | 1923 InitCrashReporter(process_type, sanitization_info); |
1906 } | 1924 } |
1907 | 1925 |
| 1926 void InitCrashKeysForTesting() { |
| 1927 InitCrashKeys(); |
| 1928 } |
| 1929 |
1908 void InitCrashReporter(const std::string& process_type, | 1930 void InitCrashReporter(const std::string& process_type, |
1909 const SanitizationInfo& sanitization_info) { | 1931 const SanitizationInfo& sanitization_info) { |
1910 #else | 1932 #else |
1911 void InitCrashReporter(const std::string& process_type) { | 1933 void InitCrashReporter(const std::string& process_type) { |
1912 #endif // defined(OS_ANDROID) | 1934 #endif // defined(OS_ANDROID) |
1913 // The maximum lengths specified by breakpad include the trailing NULL, so the | 1935 // The maximum lengths specified by breakpad include the trailing NULL, so the |
1914 // actual length of the chunk is one less. | 1936 // actual length of the chunk is one less. |
1915 static_assert(crash_keys::kChunkMaxLength == 63, "kChunkMaxLength mismatch"); | 1937 static_assert(crash_keys::kChunkMaxLength == 63, "kChunkMaxLength mismatch"); |
1916 static_assert(crash_keys::kSmallSize <= crash_keys::kChunkMaxLength, | 1938 static_assert(crash_keys::kSmallSize <= crash_keys::kChunkMaxLength, |
1917 "crash key chunk size too small"); | 1939 "crash key chunk size too small"); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2059 void SuppressDumpGeneration() { | 2081 void SuppressDumpGeneration() { |
2060 g_dumps_suppressed = G_DUMPS_SUPPRESSED_MAGIC; | 2082 g_dumps_suppressed = G_DUMPS_SUPPRESSED_MAGIC; |
2061 } | 2083 } |
2062 #endif // OS_ANDROID | 2084 #endif // OS_ANDROID |
2063 | 2085 |
2064 bool IsCrashReporterEnabled() { | 2086 bool IsCrashReporterEnabled() { |
2065 return g_is_crash_reporter_enabled; | 2087 return g_is_crash_reporter_enabled; |
2066 } | 2088 } |
2067 | 2089 |
2068 } // namespace breakpad | 2090 } // namespace breakpad |
OLD | NEW |