From 78ee270388ed0f25995c953f426bc84767c71e8a Mon Sep 17 00:00:00 2001 From: Sandboxed API Team Date: Mon, 25 Jul 2022 08:27:27 -0700 Subject: [PATCH] Remove information about in-progress syscalls on process exit. PiperOrigin-RevId: 463091104 Change-Id: I402cb61e9e816a20a87274ea874cddf91c101e14 --- sandboxed_api/sandbox2/monitor.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sandboxed_api/sandbox2/monitor.cc b/sandboxed_api/sandbox2/monitor.cc index 227109f..7f81551 100644 --- a/sandboxed_api/sandbox2/monitor.cc +++ b/sandboxed_api/sandbox2/monitor.cc @@ -816,8 +816,7 @@ void Monitor::ActionProcessSyscall(Regs* regs, const Syscall& syscall) { if (trace_response == Notify::TraceAction::kInspectAfterReturn) { // Note that a process might die without an exit-stop before the syscall is // completed (eg. a thread calls execve() and the thread group leader dies), - // so this entry might never get removed from the table. This may increase - // the monitor's memory usage by O(number-of-sandboxed-pids). + // so the entry is removed when the process exits. syscalls_in_progress_[regs->pid()] = syscall; CompleteSyscall(regs->pid(), 0); return; @@ -985,6 +984,9 @@ void Monitor::EventPtraceExec(pid_t pid, int event_msg) { } void Monitor::EventPtraceExit(pid_t pid, int event_msg) { + // Forget about any syscalls in progress for this PID. + syscalls_in_progress_.erase(pid); + // A regular exit, let it continue (fast-path). if (ABSL_PREDICT_TRUE( WIFEXITED(event_msg) &&