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

Side by Side Diff: util/mach/exception_ports_test.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,
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (exception == EXC_CRASH && code_count >= 1) { 190 if (exception == EXC_CRASH && code_count >= 1) {
191 int signal; 191 int signal;
192 ExcCrashRecoverOriginalException(code[0], nullptr, &signal); 192 ExcCrashRecoverOriginalException(code[0], nullptr, &signal);
193 193
194 // The child crashed with __builtin_trap(), which shows up as SIGILL. 194 // The child crashed with __builtin_trap(), which shows up as SIGILL.
195 EXPECT_EQ(SIGILL, signal); 195 EXPECT_EQ(SIGILL, signal);
196 196
197 SetExpectedChildTermination(kTerminationSignal, signal); 197 SetExpectedChildTermination(kTerminationSignal, signal);
198 } 198 }
199 199
200 EXPECT_EQ(0, AuditPIDFromMachMessageTrailer(trailer));
201
200 return ExcServerSuccessfulReturnValue(behavior, false); 202 return ExcServerSuccessfulReturnValue(behavior, false);
201 } 203 }
202 204
203 private: 205 private:
204 class Child { 206 class Child {
205 public: 207 public:
206 explicit Child(TestExceptionPorts* test_exception_ports) 208 explicit Child(TestExceptionPorts* test_exception_ports)
207 : test_exception_ports_(test_exception_ports), 209 : test_exception_ports_(test_exception_ports),
208 thread_(), 210 thread_(),
209 init_semaphore_(0), 211 init_semaphore_(0),
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 435
434 // Let the child process know that everything in the parent process is set 436 // Let the child process know that everything in the parent process is set
435 // up. 437 // up.
436 c = '\0'; 438 c = '\0';
437 CheckedWriteFile(WritePipeHandle(), &c, 1); 439 CheckedWriteFile(WritePipeHandle(), &c, 1);
438 440
439 if (who_crashes_ != kNobodyCrashes) { 441 if (who_crashes_ != kNobodyCrashes) {
440 UniversalMachExcServer universal_mach_exc_server(this); 442 UniversalMachExcServer universal_mach_exc_server(this);
441 443
442 const mach_msg_timeout_t kTimeoutMs = 50; 444 const mach_msg_timeout_t kTimeoutMs = 50;
443 kern_return_t kr = 445 kern_return_t kr = MachMessageServer::Run(
444 MachMessageServer::Run(&universal_mach_exc_server, 446 &universal_mach_exc_server,
445 local_port, 447 local_port,
446 MACH_MSG_OPTION_NONE, 448 MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) |
447 MachMessageServer::kOneShot, 449 MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT),
448 MachMessageServer::kReceiveLargeError, 450 MachMessageServer::kOneShot,
449 kTimeoutMs); 451 MachMessageServer::kReceiveLargeError,
452 kTimeoutMs);
450 EXPECT_EQ(KERN_SUCCESS, kr) 453 EXPECT_EQ(KERN_SUCCESS, kr)
451 << MachErrorMessage(kr, "MachMessageServer::Run"); 454 << MachErrorMessage(kr, "MachMessageServer::Run");
452 455
453 EXPECT_TRUE(handled_); 456 EXPECT_TRUE(handled_);
454 } 457 }
455 458
456 // Wait for the child process to exit or terminate, as indicated by it 459 // Wait for the child process to exit or terminate, as indicated by it
457 // closing its pipe. This keeps LocalPort() alive in the child as 460 // closing its pipe. This keeps LocalPort() alive in the child as
458 // RemotePort(), for the child’s use in its TestGetExceptionPorts(). 461 // RemotePort(), for the child’s use in its TestGetExceptionPorts().
459 CheckedReadFileAtEOF(ReadPipeHandle()); 462 CheckedReadFileAtEOF(ReadPipeHandle());
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 if (geteuid() == 0) { 607 if (geteuid() == 0) {
605 EXPECT_TRUE(rv); 608 EXPECT_TRUE(rv);
606 } else { 609 } else {
607 EXPECT_FALSE(rv); 610 EXPECT_FALSE(rv);
608 } 611 }
609 } 612 }
610 613
611 } // namespace 614 } // namespace
612 } // namespace test 615 } // namespace test
613 } // namespace crashpad 616 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698