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 12 matching lines...) Expand all Loading... |
23 #include <unistd.h> | 23 #include <unistd.h> |
24 | 24 |
25 #include <algorithm> | 25 #include <algorithm> |
26 #include <string> | 26 #include <string> |
27 | 27 |
28 #include "base/base_switches.h" | 28 #include "base/base_switches.h" |
29 #include "base/command_line.h" | 29 #include "base/command_line.h" |
30 #include "base/debug/crash_logging.h" | 30 #include "base/debug/crash_logging.h" |
31 #include "base/debug/dump_without_crashing.h" | 31 #include "base/debug/dump_without_crashing.h" |
32 #include "base/files/file_path.h" | 32 #include "base/files/file_path.h" |
| 33 #include "base/format_macros.h" |
33 #include "base/lazy_instance.h" | 34 #include "base/lazy_instance.h" |
34 #include "base/linux_util.h" | 35 #include "base/linux_util.h" |
35 #include "base/macros.h" | 36 #include "base/macros.h" |
36 #include "base/path_service.h" | 37 #include "base/path_service.h" |
37 #include "base/posix/eintr_wrapper.h" | 38 #include "base/posix/eintr_wrapper.h" |
38 #include "base/posix/global_descriptors.h" | 39 #include "base/posix/global_descriptors.h" |
39 #include "base/process/memory.h" | 40 #include "base/process/memory.h" |
40 #include "base/strings/string_split.h" | 41 #include "base/strings/string_split.h" |
41 #include "base/strings/string_util.h" | 42 #include "base/strings/string_util.h" |
| 43 #include "base/strings/stringprintf.h" |
42 #include "base/threading/thread_checker.h" | 44 #include "base/threading/thread_checker.h" |
43 #include "breakpad/src/client/linux/crash_generation/crash_generation_client.h" | 45 #include "breakpad/src/client/linux/crash_generation/crash_generation_client.h" |
44 #include "breakpad/src/client/linux/handler/exception_handler.h" | 46 #include "breakpad/src/client/linux/handler/exception_handler.h" |
45 #include "breakpad/src/client/linux/minidump_writer/directory_reader.h" | 47 #include "breakpad/src/client/linux/minidump_writer/directory_reader.h" |
46 #include "breakpad/src/common/linux/linux_libc_support.h" | 48 #include "breakpad/src/common/linux/linux_libc_support.h" |
47 #include "breakpad/src/common/memory.h" | 49 #include "breakpad/src/common/memory.h" |
48 #include "build/build_config.h" | 50 #include "build/build_config.h" |
49 #include "components/crash/content/app/breakpad_linux_impl.h" | 51 #include "components/crash/content/app/breakpad_linux_impl.h" |
50 #include "components/crash/content/app/crash_reporter_client.h" | 52 #include "components/crash/content/app/crash_reporter_client.h" |
51 #include "components/crash/core/common/crash_keys.h" | 53 #include "components/crash/core/common/crash_keys.h" |
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. | 1093 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. |
1092 nullptr, | 1094 nullptr, |
1093 nullptr, | 1095 nullptr, |
1094 nullptr, | 1096 nullptr, |
1095 true, | 1097 true, |
1096 -1); | 1098 -1); |
1097 g_breakpad->set_crash_generation_client(new NonBrowserCrashHandler()); | 1099 g_breakpad->set_crash_generation_client(new NonBrowserCrashHandler()); |
1098 } | 1100 } |
1099 #endif // defined(OS_ANDROID) | 1101 #endif // defined(OS_ANDROID) |
1100 | 1102 |
| 1103 bool g_use_crash_keys_whitelist; |
| 1104 std::vector<const char*> g_crash_keys_whitelist; |
| 1105 |
| 1106 void SetupCrashKeysWhiteList(bool use_white_list, |
| 1107 const std::vector<const char*>& keys) { |
| 1108 g_use_crash_keys_whitelist = use_white_list; |
| 1109 g_crash_keys_whitelist = keys; |
| 1110 LOG(ERROR) << "in SetupCrashKeysWhiteList, whitelist length: " << keys.size(); |
| 1111 for (size_t i = 0; i < keys.size(); ++i) { |
| 1112 LOG(ERROR) << "in SetupCrashKeysWhiteList, entry: " |
| 1113 << g_crash_keys_whitelist.data()[i]; |
| 1114 } |
| 1115 } |
| 1116 |
| 1117 bool IsInWhiteList(const base::StringPiece& key) { |
| 1118 for (size_t i = 0; i < g_crash_keys_whitelist.size(); ++i) { |
| 1119 LOG(ERROR) << "in SetupCrashKeysWhiteList, entry: " |
| 1120 << g_crash_keys_whitelist.data()[i]; |
| 1121 if (0 == my_strcmp(g_crash_keys_whitelist.data()[i], key.data())) { |
| 1122 return true; |
| 1123 } |
| 1124 } |
| 1125 return false; |
| 1126 } |
| 1127 |
1101 void SetCrashKeyValue(const base::StringPiece& key, | 1128 void SetCrashKeyValue(const base::StringPiece& key, |
1102 const base::StringPiece& value) { | 1129 const base::StringPiece& value) { |
1103 g_crash_keys->SetKeyValue(key.data(), value.data()); | 1130 LOG(ERROR) << "in SetCrashKeyValue for key " << key.data(); |
| 1131 if (!g_use_crash_keys_whitelist || IsInWhiteList(key)) { |
| 1132 LOG(ERROR) << "in SetCrashKeyValue for key " << key.data() |
| 1133 << " it is in the whitelist :D"; |
| 1134 g_crash_keys->SetKeyValue(key.data(), value.data()); |
| 1135 } else { |
| 1136 LOG(ERROR) << "in SetCrashKeyValue for key " << key.data() |
| 1137 << ", not in the whitelist"; |
| 1138 } |
1104 } | 1139 } |
1105 | 1140 |
1106 void ClearCrashKey(const base::StringPiece& key) { | 1141 void ClearCrashKey(const base::StringPiece& key) { |
1107 g_crash_keys->RemoveKey(key.data()); | 1142 g_crash_keys->RemoveKey(key.data()); |
1108 } | 1143 } |
1109 | 1144 |
1110 // GetCrashReporterClient() cannot call any Set methods until after | 1145 // GetCrashReporterClient() cannot call any Set methods until after |
1111 // InitCrashKeys(). | 1146 // InitCrashKeys(). |
1112 void InitCrashKeys() { | 1147 void InitCrashKeys() { |
1113 g_crash_keys = new CrashKeyStorage; | 1148 g_crash_keys = new CrashKeyStorage; |
1114 GetCrashReporterClient()->RegisterCrashKeys(); | 1149 GetCrashReporterClient()->RegisterCrashKeys(); |
| 1150 SetupCrashKeysWhiteList(GetCrashReporterClient()->UseCrashKeysWhiteList(), |
| 1151 GetCrashReporterClient()->GetWhiteListedCrashKeys()); |
1115 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValue, &ClearCrashKey); | 1152 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValue, &ClearCrashKey); |
1116 } | 1153 } |
1117 | 1154 |
1118 // Miscellaneous initialization functions to call after Breakpad has been | 1155 // Miscellaneous initialization functions to call after Breakpad has been |
1119 // enabled. | 1156 // enabled. |
1120 void PostEnableBreakpadInitialization() { | 1157 void PostEnableBreakpadInitialization() { |
1121 SetProcessStartTime(); | 1158 SetProcessStartTime(); |
1122 g_pid = getpid(); | 1159 g_pid = getpid(); |
1123 | 1160 |
1124 base::debug::SetDumpWithoutCrashingFunction(&DumpProcess); | 1161 base::debug::SetDumpWithoutCrashingFunction(&DumpProcess); |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 | 1935 |
1899 #if defined(OS_ANDROID) | 1936 #if defined(OS_ANDROID) |
1900 // In Android WebView, microdumps are generated conditionally (depending on the | 1937 // In Android WebView, microdumps are generated conditionally (depending on the |
1901 // cause of the crash) and can be sanitized to prevent exposing unnecessary data | 1938 // cause of the crash) and can be sanitized to prevent exposing unnecessary data |
1902 // from the embedding application. | 1939 // from the embedding application. |
1903 void InitCrashReporter(const std::string& process_type) { | 1940 void InitCrashReporter(const std::string& process_type) { |
1904 SanitizationInfo sanitization_info; | 1941 SanitizationInfo sanitization_info; |
1905 InitCrashReporter(process_type, sanitization_info); | 1942 InitCrashReporter(process_type, sanitization_info); |
1906 } | 1943 } |
1907 | 1944 |
| 1945 void InitCrashKeysForTesting() { |
| 1946 InitCrashKeys(); |
| 1947 } |
| 1948 |
1908 void InitCrashReporter(const std::string& process_type, | 1949 void InitCrashReporter(const std::string& process_type, |
1909 const SanitizationInfo& sanitization_info) { | 1950 const SanitizationInfo& sanitization_info) { |
1910 #else | 1951 #else |
1911 void InitCrashReporter(const std::string& process_type) { | 1952 void InitCrashReporter(const std::string& process_type) { |
1912 #endif // defined(OS_ANDROID) | 1953 #endif // defined(OS_ANDROID) |
1913 // The maximum lengths specified by breakpad include the trailing NULL, so the | 1954 // The maximum lengths specified by breakpad include the trailing NULL, so the |
1914 // actual length of the chunk is one less. | 1955 // actual length of the chunk is one less. |
1915 static_assert(crash_keys::kChunkMaxLength == 63, "kChunkMaxLength mismatch"); | 1956 static_assert(crash_keys::kChunkMaxLength == 63, "kChunkMaxLength mismatch"); |
1916 static_assert(crash_keys::kSmallSize <= crash_keys::kChunkMaxLength, | 1957 static_assert(crash_keys::kSmallSize <= crash_keys::kChunkMaxLength, |
1917 "crash key chunk size too small"); | 1958 "crash key chunk size too small"); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2059 void SuppressDumpGeneration() { | 2100 void SuppressDumpGeneration() { |
2060 g_dumps_suppressed = G_DUMPS_SUPPRESSED_MAGIC; | 2101 g_dumps_suppressed = G_DUMPS_SUPPRESSED_MAGIC; |
2061 } | 2102 } |
2062 #endif // OS_ANDROID | 2103 #endif // OS_ANDROID |
2063 | 2104 |
2064 bool IsCrashReporterEnabled() { | 2105 bool IsCrashReporterEnabled() { |
2065 return g_is_crash_reporter_enabled; | 2106 return g_is_crash_reporter_enabled; |
2066 } | 2107 } |
2067 | 2108 |
2068 } // namespace breakpad | 2109 } // namespace breakpad |
OLD | NEW |