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
pull/171/head
Wiktor Garbacz 2023-05-10 05:05:31 -07:00 committed by Copybara-Service
parent fb1571c801
commit 5b12071ba0
2 changed files with 1 additions and 2 deletions

View File

@ -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();

View File

@ -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) {