| OLD | NEW |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "base/mac/mach_logging.h" | 22 #include "base/mac/mach_logging.h" |
| 23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 24 #include "client/settings.h" | 24 #include "client/settings.h" |
| 25 #include "minidump/minidump_file_writer.h" | 25 #include "minidump/minidump_file_writer.h" |
| 26 #include "snapshot/mac/crashpad_info_client_options.h" | 26 #include "snapshot/mac/crashpad_info_client_options.h" |
| 27 #include "snapshot/mac/process_snapshot_mac.h" | 27 #include "snapshot/mac/process_snapshot_mac.h" |
| 28 #include "util/file/file_writer.h" | 28 #include "util/file/file_writer.h" |
| 29 #include "util/mach/exc_client_variants.h" | 29 #include "util/mach/exc_client_variants.h" |
| 30 #include "util/mach/exception_behaviors.h" | 30 #include "util/mach/exception_behaviors.h" |
| 31 #include "util/mach/mach_extensions.h" | 31 #include "util/mach/mach_extensions.h" |
| 32 #include "util/mach/mach_message.h" |
| 32 #include "util/mach/scoped_task_suspend.h" | 33 #include "util/mach/scoped_task_suspend.h" |
| 33 #include "util/misc/tri_state.h" | 34 #include "util/misc/tri_state.h" |
| 34 #include "util/misc/uuid.h" | 35 #include "util/misc/uuid.h" |
| 35 | 36 |
| 36 namespace crashpad { | 37 namespace crashpad { |
| 37 | 38 |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 // Calls CrashReportDatabase::ErrorWritingCrashReport() upon destruction unless | 41 // Calls CrashReportDatabase::ErrorWritingCrashReport() upon destruction unless |
| 41 // disarmed by calling Disarm(). Armed upon construction. | 42 // disarmed by calling Disarm(). Armed upon construction. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 return KERN_FAILURE; | 113 return KERN_FAILURE; |
| 113 } | 114 } |
| 114 | 115 |
| 115 ScopedTaskSuspend suspend(task); | 116 ScopedTaskSuspend suspend(task); |
| 116 | 117 |
| 117 ProcessSnapshotMac process_snapshot; | 118 ProcessSnapshotMac process_snapshot; |
| 118 if (!process_snapshot.Initialize(task)) { | 119 if (!process_snapshot.Initialize(task)) { |
| 119 return KERN_FAILURE; | 120 return KERN_FAILURE; |
| 120 } | 121 } |
| 121 | 122 |
| 123 // Check for suspicious message sources. A suspicious exception message comes |
| 124 // from a source other than the kernel or the process that the exception |
| 125 // purportedly occurred in. |
| 126 // |
| 127 // TODO(mark): Consider exceptions outside of the range (0, 32) from the |
| 128 // kernel to be suspicious, and exceptions other than kMachExceptionSimulated |
| 129 // from the process itself to be suspicious. |
| 130 pid_t audit_pid = AuditPIDFromMachMessageTrailer(trailer); |
| 131 if (audit_pid != -1 && audit_pid != 0) { |
| 132 pid_t exception_pid = process_snapshot.ProcessID(); |
| 133 if (exception_pid != audit_pid) { |
| 134 LOG(WARNING) << "exception for pid " << exception_pid << " sent by pid " |
| 135 << audit_pid; |
| 136 } |
| 137 } |
| 138 |
| 122 CrashpadInfoClientOptions client_options; | 139 CrashpadInfoClientOptions client_options; |
| 123 process_snapshot.GetCrashpadOptions(&client_options); | 140 process_snapshot.GetCrashpadOptions(&client_options); |
| 124 | 141 |
| 125 if (client_options.crashpad_handler_behavior != TriState::kDisabled) { | 142 if (client_options.crashpad_handler_behavior != TriState::kDisabled) { |
| 126 if (!process_snapshot.InitializeException(thread, | 143 if (!process_snapshot.InitializeException(thread, |
| 127 exception, | 144 exception, |
| 128 code, | 145 code, |
| 129 code_count, | 146 code_count, |
| 130 *flavor, | 147 *flavor, |
| 131 old_state, | 148 old_state, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 &new_state_forward_count); | 243 &new_state_forward_count); |
| 227 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) | 244 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) |
| 228 << "UniversalExceptionRaise " << kSystemCrashReporterServiceName; | 245 << "UniversalExceptionRaise " << kSystemCrashReporterServiceName; |
| 229 } | 246 } |
| 230 } | 247 } |
| 231 | 248 |
| 232 return ExcServerSuccessfulReturnValue(behavior, false); | 249 return ExcServerSuccessfulReturnValue(behavior, false); |
| 233 } | 250 } |
| 234 | 251 |
| 235 } // namespace crashpad | 252 } // namespace crashpad |
| OLD | NEW |