Commit 47f35a31 authored by Joe Mason's avatar Joe Mason Committed by Commit Bot

Call ReportProcessLaunchAttempted when launching a mojo-connected sandbox

R=csharp@chromium.org

Bug: 830892
Change-Id: I13ef01f4194bc747b4c9ea28537a188aa9315c49
Reviewed-on: https://chromium-review.googlesource.com/c/1336067
Commit-Queue: Joe Mason <joenotcharles@google.com>
Reviewed-by: default avatarChris Sharp <csharp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608418}
parent e08eb164
......@@ -43,6 +43,8 @@ ResultCode MojoSandboxSetupHooks::TargetSpawned(
const base::win::ScopedHandle& target_thread) {
DCHECK(message_pipe_was_created_);
ReportProcessLaunchAttempt();
// TODO(joenotcharles): Hook up the |error_callback| parameter of Send to a
// function that logs a security warning and exits. This callback will be
// called when an invalid message is written to the pipe.
......@@ -53,6 +55,22 @@ ResultCode MojoSandboxSetupHooks::TargetSpawned(
return RESULT_CODE_SUCCESS;
}
void MojoSandboxSetupHooks::SetupFailed() {
if (process_launch_attempt_reported_) {
// Setup failed after calling TargetSpawned, so don't report the launch
// attempt again.
return;
}
ReportProcessLaunchAttempt();
}
void MojoSandboxSetupHooks::ReportProcessLaunchAttempt() {
DCHECK(!process_launch_attempt_reported_);
mojo_channel_.RemoteProcessLaunchAttempted();
process_launch_attempt_reported_ = true;
}
MojoSandboxTargetHooks::MojoSandboxTargetHooks() = default;
MojoSandboxTargetHooks::~MojoSandboxTargetHooks() = default;
......
......@@ -34,8 +34,13 @@ class MojoSandboxSetupHooks : public SandboxSetupHooks {
const base::Process& target_process,
const base::win::ScopedHandle& target_thread) override;
void SetupFailed() override;
private:
void ReportProcessLaunchAttempt();
bool message_pipe_was_created_ = false;
bool process_launch_attempt_reported_ = false;
mojo::OutgoingInvitation outgoing_invitation_;
mojo::PlatformChannel mojo_channel_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment