Skip to content

Commit fc6300e

Browse files
Sandboxed API Teamcopybara-github
authored andcommitted
Add a flag to control kill timeout duration.
PiperOrigin-RevId: 794667661 Change-Id: Ib0dce56783109bd587ca452e36d14a0dcb14b9a8
1 parent 56046d6 commit fc6300e

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

sandboxed_api/sandbox2/flags.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ ABSL_FLAG(absl::Duration, sandbox2_stack_traces_collection_timeout,
4545
"How much time should be spent on logging threads' stack traces on "
4646
"monitor shut down. Only relevent when collection of all stack "
4747
"traces is enabled.");
48+
ABSL_FLAG(absl::Duration, sandbox2_monitor_ptrace_graceful_kill_timeout,
49+
absl::Seconds(1),
50+
"Timeout after SIGKILL is sent to the sandboxee until the monitor "
51+
"stops and the sandboxee is terminated via PTRACE_O_EXITKILL");
4852

4953
// sandbox2:policy
5054
ABSL_FLAG(bool, sandbox2_danger_danger_permit_all, false,

sandboxed_api/sandbox2/flags.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ ABSL_DECLARE_FLAG(bool, sandbox2_log_all_stack_traces);
7070
ABSL_DECLARE_FLAG(bool, sandbox2_monitor_ptrace_use_deadline_manager);
7171
ABSL_DECLARE_FLAG(bool, sandbox2_log_unobtainable_stack_traces_errors);
7272
ABSL_DECLARE_FLAG(absl::Duration, sandbox2_stack_traces_collection_timeout);
73+
ABSL_DECLARE_FLAG(absl::Duration,
74+
sandbox2_monitor_ptrace_graceful_kill_timeout);
7375

7476
// sandbox2:global_forkserver
7577
ABSL_DECLARE_FLAG(std::string, sandbox2_forkserver_binary_path);

sandboxed_api/sandbox2/monitor_ptrace.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ bool PtraceMonitor::KillSandboxee() {
159159
SetExitStatusCode(Result::INTERNAL_ERROR, Result::FAILED_KILL);
160160
return false;
161161
}
162-
constexpr absl::Duration kGracefullKillTimeout = absl::Milliseconds(1000);
163162
if (hard_deadline_ == absl::InfiniteFuture()) {
164-
hard_deadline_ = absl::Now() + kGracefullKillTimeout;
163+
hard_deadline_ =
164+
absl::Now() +
165+
absl::GetFlag(FLAGS_sandbox2_monitor_ptrace_graceful_kill_timeout);
165166
}
166167
return true;
167168
}

0 commit comments

Comments
 (0)