Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: handler/mac/crash_report_exception_handler.cc

Issue 1001943002: handler/mac: Log a warning when an exception message has a suspicious (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: MACH_MSG_TYPE_MAKE_SEND_ONCE Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | handler/mac/exception_handler_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | handler/mac/exception_handler_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698