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

Unified Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 2054303002: Kill child processes on bad Mojo messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bad-message
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index c6ee319c3f781f8a09e389c4fa06e16d5fbb0280..60880df5dc2e2393649fc1e053a1eff51ddff3ca 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -784,7 +784,10 @@ bool RenderProcessHostImpl::Init() {
// at this stage.
child_process_launcher_.reset(new ChildProcessLauncher(
new RendererSandboxedProcessLauncherDelegate(channel_.get()), cmd_line,
- GetID(), this, child_token_));
+ GetID(), this, child_token_,
+ base::Bind(&RenderProcessHostImpl::OnMojoError,
+ weak_factory_.GetWeakPtr(),
+ base::ThreadTaskRunnerHandle::Get())));
fast_shutdown_started_ = false;
}
@@ -2806,4 +2809,25 @@ void RenderProcessHostImpl::RecomputeAndUpdateWebKitPreferences() {
}
}
+// static
+void RenderProcessHostImpl::OnMojoError(
+ base::WeakPtr<RenderProcessHostImpl> process,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ const std::string& error) {
+ if (!task_runner->BelongsToCurrentThread()) {
+ task_runner->PostTask(FROM_HERE,
+ base::Bind(&RenderProcessHostImpl::OnMojoError,
+ process, task_runner, error));
+ }
+ if (!process)
+ return;
+ LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
+
+ // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias
+ // enough information here so that we can determine what the bad message was.
+ base::debug::Alias(&error);
+ bad_message::ReceivedBadMessage(process.get(),
+ bad_message::RPH_MOJO_PROCESS_ERROR);
+}
+
} // namespace content
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/public/renderer/content_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698