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

Side by Side Diff: handler/mac/exception_handler_server.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: 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
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "handler/mac/exception_handler_server.h" 15 #include "handler/mac/exception_handler_server.h"
16 16
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/mac/mach_logging.h" 18 #include "base/mac/mach_logging.h"
19 #include "util/mach/composite_mach_message_server.h" 19 #include "util/mach/composite_mach_message_server.h"
20 #include "util/mach/mach_extensions.h" 20 #include "util/mach/mach_extensions.h"
21 #include "util/mach/mach_message.h" 21 #include "util/mach/mach_message.h"
22 #include "util/mach/mach_message_server.h" 22 #include "util/mach/mach_message_server.h"
23 #include "util/mach/notify_server.h" 23 #include "util/mach/notify_server.h"
24 24
25 namespace crashpad { 25 namespace crashpad {
26 26
27 namespace { 27 namespace {
28 28
29 class ExceptionHandlerServerRun 29 class ExceptionHandlerServerRun : public UniversalMachExcServer::Interface,
30 : public UniversalMachExcServer::Interface, 30 public NotifyServer::Interface {
31 public NotifyServer::Interface {
32 public: 31 public:
33 ExceptionHandlerServerRun( 32 ExceptionHandlerServerRun(
34 mach_port_t exception_port, 33 mach_port_t exception_port,
35 UniversalMachExcServer::Interface* exception_interface) 34 UniversalMachExcServer::Interface* exception_interface)
36 : UniversalMachExcServer::Interface(), 35 : UniversalMachExcServer::Interface(),
37 NotifyServer::Interface(), 36 NotifyServer::Interface(),
38 mach_exc_server_(this), 37 mach_exc_server_(this),
39 notify_server_(this), 38 notify_server_(this),
40 composite_mach_message_server_(), 39 composite_mach_message_server_(),
41 exception_interface_(exception_interface), 40 exception_interface_(exception_interface),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 kr = mach_port_insert_member( 89 kr = mach_port_insert_member(
91 mach_task_self(), notify_port_, server_port_set); 90 mach_task_self(), notify_port_, server_port_set);
92 MACH_CHECK(kr == KERN_SUCCESS, kr) << "mach_port_insert_member"; 91 MACH_CHECK(kr == KERN_SUCCESS, kr) << "mach_port_insert_member";
93 92
94 // Run the server in kOneShot mode so that running_ can be reevaluated after 93 // Run the server in kOneShot mode so that running_ can be reevaluated after
95 // each message. Receipt of a valid no-senders notification causes it to be 94 // each message. Receipt of a valid no-senders notification causes it to be
96 // set to false. 95 // set to false.
97 while (running_) { 96 while (running_) {
98 // This will result in a call to CatchMachException() or 97 // This will result in a call to CatchMachException() or
99 // DoMachNotifyNoSenders() as appropriate. 98 // DoMachNotifyNoSenders() as appropriate.
100 mach_msg_return_t mr = 99 mach_msg_return_t mr = MachMessageServer::Run(
101 MachMessageServer::Run(&composite_mach_message_server_, 100 &composite_mach_message_server_,
102 server_port_set, 101 server_port_set,
103 MACH_MSG_OPTION_NONE, 102 MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) |
104 MachMessageServer::kOneShot, 103 MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT),
105 MachMessageServer::kReceiveLargeIgnore, 104 MachMessageServer::kOneShot,
106 kMachMessageTimeoutWaitIndefinitely); 105 MachMessageServer::kReceiveLargeIgnore,
106 kMachMessageTimeoutWaitIndefinitely);
107 MACH_CHECK(mr == MACH_MSG_SUCCESS, mr) << "MachMessageServer::Run"; 107 MACH_CHECK(mr == MACH_MSG_SUCCESS, mr) << "MachMessageServer::Run";
108 } 108 }
109 } 109 }
110 110
111 // UniversalMachExcServer::Interface: 111 // UniversalMachExcServer::Interface:
112 112
113 kern_return_t CatchMachException(exception_behavior_t behavior, 113 kern_return_t CatchMachException(exception_behavior_t behavior,
114 exception_handler_t exception_port, 114 exception_handler_t exception_port,
115 thread_t thread, 115 thread_t thread,
116 task_t task, 116 task_t task,
(...skipping 24 matching lines...) Expand all
141 old_state_count, 141 old_state_count,
142 new_state, 142 new_state,
143 new_state_count, 143 new_state_count,
144 trailer, 144 trailer,
145 destroy_complex_request); 145 destroy_complex_request);
146 } 146 }
147 147
148 // NotifyServer::Interface: 148 // NotifyServer::Interface:
149 149
150 kern_return_t DoMachNotifyPortDeleted( 150 kern_return_t DoMachNotifyPortDeleted(
151 notify_port_t notify, 151 notify_port_t notify,
152 mach_port_name_t name, 152 mach_port_name_t name,
153 const mach_msg_trailer_t* trailer) override { 153 const mach_msg_trailer_t* trailer) override {
154 return UnimplementedNotifyRoutine(notify); 154 return UnimplementedNotifyRoutine(notify);
155 } 155 }
156 156
157 kern_return_t DoMachNotifyPortDestroyed(notify_port_t notify, 157 kern_return_t DoMachNotifyPortDestroyed(notify_port_t notify,
158 mach_port_t rights, 158 mach_port_t rights,
159 const mach_msg_trailer_t* trailer, 159 const mach_msg_trailer_t* trailer,
160 bool* destroy_request) override { 160 bool* destroy_request) override {
161 *destroy_request = true; 161 *destroy_request = true;
162 return UnimplementedNotifyRoutine(notify); 162 return UnimplementedNotifyRoutine(notify);
163 } 163 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 ExceptionHandlerServer::~ExceptionHandlerServer() { 228 ExceptionHandlerServer::~ExceptionHandlerServer() {
229 } 229 }
230 230
231 void ExceptionHandlerServer::Run( 231 void ExceptionHandlerServer::Run(
232 UniversalMachExcServer::Interface* exception_interface) { 232 UniversalMachExcServer::Interface* exception_interface) {
233 ExceptionHandlerServerRun run(receive_port_, exception_interface); 233 ExceptionHandlerServerRun run(receive_port_, exception_interface);
234 run.Run(); 234 run.Run();
235 } 235 }
236 236
237 } // namespace crashpad 237 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698