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

Side by Side Diff: content/browser/child_process_launcher.cc

Issue 2054303002: Kill child processes on bad Mojo messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bad-message
Patch Set: . Created 4 years, 6 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/child_process_launcher.h" 5 #include "content/browser/child_process_launcher.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 389 }
390 390
391 } // namespace 391 } // namespace
392 392
393 ChildProcessLauncher::ChildProcessLauncher( 393 ChildProcessLauncher::ChildProcessLauncher(
394 SandboxedProcessLauncherDelegate* delegate, 394 SandboxedProcessLauncherDelegate* delegate,
395 base::CommandLine* cmd_line, 395 base::CommandLine* cmd_line,
396 int child_process_id, 396 int child_process_id,
397 Client* client, 397 Client* client,
398 const std::string& mojo_child_token, 398 const std::string& mojo_child_token,
399 const mojo::edk::ProcessErrorCallback& process_error_callback,
399 bool terminate_on_shutdown) 400 bool terminate_on_shutdown)
400 : client_(client), 401 : client_(client),
401 termination_status_(base::TERMINATION_STATUS_NORMAL_TERMINATION), 402 termination_status_(base::TERMINATION_STATUS_NORMAL_TERMINATION),
402 exit_code_(RESULT_CODE_NORMAL_EXIT), 403 exit_code_(RESULT_CODE_NORMAL_EXIT),
403 zygote_(nullptr), 404 zygote_(nullptr),
404 starting_(true), 405 starting_(true),
406 process_error_callback_(process_error_callback),
405 #if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ 407 #if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \
406 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \ 408 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \
407 defined(UNDEFINED_SANITIZER) 409 defined(UNDEFINED_SANITIZER)
408 terminate_child_on_shutdown_(false), 410 terminate_child_on_shutdown_(false),
409 #else 411 #else
410 terminate_child_on_shutdown_(terminate_on_shutdown), 412 terminate_child_on_shutdown_(terminate_on_shutdown),
411 #endif 413 #endif
412 mojo_child_token_(mojo_child_token), 414 mojo_child_token_(mojo_child_token),
413 weak_factory_(this) { 415 weak_factory_(this) {
414 DCHECK(CalledOnValidThread()); 416 DCHECK(CalledOnValidThread());
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 base::ScopedFD ipcfd, 553 base::ScopedFD ipcfd,
552 #endif 554 #endif
553 base::Process process, 555 base::Process process,
554 int error_code) { 556 int error_code) {
555 DCHECK(CalledOnValidThread()); 557 DCHECK(CalledOnValidThread());
556 starting_ = false; 558 starting_ = false;
557 process_ = std::move(process); 559 process_ = std::move(process);
558 560
559 if (process_.IsValid()) { 561 if (process_.IsValid()) {
560 // Set up Mojo IPC to the new process. 562 // Set up Mojo IPC to the new process.
561 mojo::edk::ChildProcessLaunched(process_.Handle(), 563 mojo::edk::ChildProcessLaunched(process_.Handle(),
jam 2016/06/13 23:27:12 nit: ChildProcessLaunche's documentation should me
Ken Rockot(use gerrit already) 2016/06/14 00:28:02 done
562 std::move(mojo_host_platform_handle_), 564 std::move(mojo_host_platform_handle_),
563 mojo_child_token_); 565 mojo_child_token_,
566 process_error_callback_);
564 } 567 }
565 568
566 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) 569 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
567 zygote_ = zygote; 570 zygote_ = zygote;
568 #endif 571 #endif
569 if (process_.IsValid()) { 572 if (process_.IsValid()) {
570 client_->OnProcessLaunched(); 573 client_->OnProcessLaunched();
571 } else { 574 } else {
572 mojo::edk::ChildProcessLaunchFailed(mojo_child_token_); 575 mojo::edk::ChildProcessLaunchFailed(mojo_child_token_);
573 termination_status_ = base::TERMINATION_STATUS_LAUNCH_FAILED; 576 termination_status_ = base::TERMINATION_STATUS_LAUNCH_FAILED;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 } 618 }
616 619
617 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest( 620 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest(
618 Client* client) { 621 Client* client) {
619 Client* ret = client_; 622 Client* ret = client_;
620 client_ = client; 623 client_ = client;
621 return ret; 624 return ret;
622 } 625 }
623 626
624 } // namespace content 627 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/child_process_launcher.h ('k') | content/browser/renderer_host/render_process_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698