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

Side by Side Diff: util/mach/mach_message.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 | « util/mach/mach_message.h ('k') | util/mach/mach_message_test.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 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 "util/mach/mach_message.h" 15 #include "util/mach/mach_message.h"
16 16
17 #include <AvailabilityMacros.h>
18 #include <bsm/libbsm.h>
19
17 #include <limits> 20 #include <limits>
18 21
19 #include "base/basictypes.h" 22 #include "base/basictypes.h"
23 #include "base/logging.h"
20 #include "util/misc/clock.h" 24 #include "util/misc/clock.h"
21 25
22 namespace crashpad { 26 namespace crashpad {
23 27
24 namespace { 28 namespace {
25 29
26 const int kNanosecondsPerMillisecond = 1E6; 30 const int kNanosecondsPerMillisecond = 1E6;
27 31
28 // TimerRunning() determines whether |deadline| has passed. If |deadline| is 32 // TimerRunning() determines whether |deadline| has passed. If |deadline| is
29 // kMachMessageDeadlineWaitIndefinitely, |*timeout_options| is set to 33 // kMachMessageDeadlineWaitIndefinitely, |*timeout_options| is set to
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 reinterpret_cast<mig_reply_error_t*>(out_header)->RetCode = error; 210 reinterpret_cast<mig_reply_error_t*>(out_header)->RetCode = error;
207 } 211 }
208 212
209 const mach_msg_trailer_t* MachMessageTrailerFromHeader( 213 const mach_msg_trailer_t* MachMessageTrailerFromHeader(
210 const mach_msg_header_t* header) { 214 const mach_msg_header_t* header) {
211 vm_address_t header_address = reinterpret_cast<vm_address_t>(header); 215 vm_address_t header_address = reinterpret_cast<vm_address_t>(header);
212 vm_address_t trailer_address = header_address + round_msg(header->msgh_size); 216 vm_address_t trailer_address = header_address + round_msg(header->msgh_size);
213 return reinterpret_cast<const mach_msg_trailer_t*>(trailer_address); 217 return reinterpret_cast<const mach_msg_trailer_t*>(trailer_address);
214 } 218 }
215 219
220 pid_t AuditPIDFromMachMessageTrailer(const mach_msg_trailer_t* trailer) {
221 if (trailer->msgh_trailer_type != MACH_MSG_TRAILER_FORMAT_0) {
222 LOG(ERROR) << "unexpected msgh_trailer_type " << trailer->msgh_trailer_type;
223 return -1;
224 }
225 if (trailer->msgh_trailer_size <
226 REQUESTED_TRAILER_SIZE(kMachMessageReceiveAuditTrailer)) {
227 LOG(ERROR) << "small msgh_trailer_size " << trailer->msgh_trailer_size;
228 return -1;
229 }
230
231 const mach_msg_audit_trailer_t* audit_trailer =
232 reinterpret_cast<const mach_msg_audit_trailer_t*>(trailer);
233
234 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
235 pid_t audit_pid;
236 audit_token_to_au32(audit_trailer->msgh_audit,
237 nullptr,
238 nullptr,
239 nullptr,
240 nullptr,
241 nullptr,
242 &audit_pid,
243 nullptr,
244 nullptr);
245 #else
246 pid_t audit_pid = audit_token_to_pid(audit_trailer->msgh_audit);
247 #endif
248
249 return audit_pid;
250 }
251
216 } // namespace crashpad 252 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/mach/mach_message.h ('k') | util/mach/mach_message_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698