From 5b12071ba0fa35b1f799528fe3c5c08a54023e52 Mon Sep 17 00:00:00 2001 From: Wiktor Garbacz Date: Wed, 10 May 2023 05:05:31 -0700 Subject: [PATCH] Remove WaitForSanitizers from ptrace monitor & add to global forkserver This makes should ensure global forkserver will be single threaded before forking the sandboxees as it does not go through WaitAndFork. Waiting for sanitizers is not needed in the monitor and should reduce latency by 1 second for all sanitizer builds. Currently it'll always wait up to 1 seconds for the process to become single-threaded, which will never happen as monitor itself is running in a separate thread. PiperOrigin-RevId: 530878018 Change-Id: Ie9f663848502f2738721861b0ba2dc6f3cc9f1c9 --- sandboxed_api/sandbox2/forkserver_bin.cc | 1 + sandboxed_api/sandbox2/monitor_ptrace.cc | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sandboxed_api/sandbox2/forkserver_bin.cc b/sandboxed_api/sandbox2/forkserver_bin.cc index 65f20de..b856750 100644 --- a/sandboxed_api/sandbox2/forkserver_bin.cc +++ b/sandboxed_api/sandbox2/forkserver_bin.cc @@ -63,6 +63,7 @@ int main(int argc, char* argv[]) { sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection); sandbox2::ForkServer fork_server(&comms); + sandbox2::sanitizer::WaitForSanitizer(); while (!fork_server.IsTerminated()) { pid_t child_pid = fork_server.ServeRequest(); diff --git a/sandboxed_api/sandbox2/monitor_ptrace.cc b/sandboxed_api/sandbox2/monitor_ptrace.cc index 00b4430..6b883c3 100644 --- a/sandboxed_api/sandbox2/monitor_ptrace.cc +++ b/sandboxed_api/sandbox2/monitor_ptrace.cc @@ -487,8 +487,6 @@ bool PtraceMonitor::InitSetupSignals() { } bool PtraceMonitor::InitPtraceAttach() { - sanitizer::WaitForSanitizer(); - if (process_.init_pid > 0) { if (ptrace(PTRACE_SEIZE, process_.init_pid, 0, PTRACE_O_EXITKILL) != 0) { if (errno != ESRCH) {