Commit 95cd3c10 authored by Joshua Peraza's avatar Joshua Peraza Committed by Commit Bot

linux: set ptracer at fork

Sandboxed processes configure the handler as their ptracer but this
relationship is not inherited by any children they spawn, such as the
syscall broker.

Bug: 1009785
Change-Id: I5356fbfb588a3e47550cac9be45d419d3784e5ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1845579Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703752}
parent 7e7e8538
......@@ -4,9 +4,13 @@
#include "components/crash/content/app/crashpad.h"
#include <pthread.h>
#include <sys/prctl.h>
#include <limits>
#include "base/command_line.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/posix/global_descriptors.h"
#include "base/strings/string_number_conversions.h"
......@@ -36,6 +40,16 @@ bool GetHandlerSocket(int* fd, pid_t* pid) {
return crashpad::CrashpadClient::GetHandlerSocket(fd, pid);
}
void SetPtracerAtFork() {
pid_t pid;
if (!GetHandlerSocket(nullptr, &pid)) {
return;
}
if (pid > 0 && prctl(PR_SET_PTRACER, pid, 0, 0, 0) != 0) {
PLOG(ERROR) << "prctl";
}
}
namespace internal {
base::FilePath PlatformCrashpadInitialization(
......@@ -130,6 +144,7 @@ base::FilePath PlatformCrashpadInitialization(
annotations, arguments, false, false);
DCHECK(result);
pthread_atfork(nullptr, nullptr, SetPtracerAtFork);
return database_path;
}
......@@ -150,6 +165,7 @@ base::FilePath PlatformCrashpadInitialization(
client.SetHandlerSocket(crashpad::ScopedFileHandle(fd), pid);
pthread_atfork(nullptr, nullptr, SetPtracerAtFork);
return base::FilePath();
}
......
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