blob: d63757fe80cc5303d995f0a3ad2e899bece77022 [file] [log] [blame] [view]
andybonsad92aa32015-08-31 02:27:441# seccomp Sandbox Crash Dumping
2
3Currently, Breakpad relies on facilities that are disallowed inside the Linux
4seccomp sandbox. Specifically, it sets a signal handler to catch faults
5(currently disallowed), forks a new process, and uses ptrace() (also disallowed)
6to read the memory of the faulted process.
andybons3322f762015-08-24 21:37:097
8## Options
andybonsad92aa32015-08-31 02:27:449
andybons3322f762015-08-24 21:37:0910There are three ways we could do crash dumping of seccomp-sandboxed processes:
andybonsad92aa32015-08-31 02:27:4411
12* Find a way to permit signal handling safely inside the sandbox (see below).
13* Allow the kernel's core dumper to kick in and write a core file.
14 * This seems risky because this code tends not to be well-tested.
15 * This will not work if the process is chrooted, so it would not work if
16 the seccomp sandbox is stacked with the SUID sandbox.
17* Have an unsandboxed helper process which `ptrace()`s the sandboxed process
18 to catch faults.
andybons3322f762015-08-24 21:37:0919
20## Signal handling in the seccomp sandbox
andybonsad92aa32015-08-31 02:27:4421
22In case a trusted thread faults with a SIGSEGV, we must make sure that an
23untrusted thread cannot register a signal handler that will run in the context
24of the trusted thread.
andybons3322f762015-08-24 21:37:0925
26Here are some mechanisms that could make this safe:
andybonsad92aa32015-08-31 02:27:4427
28* `sigaltstack()` is per-thread. If we opt not to set a signal stack for
29 trusted threads, and set %esp/%rsp to an invalid address, trusted threads
30 will die safely if they fault.
31 * This means the trusted thread cannot set a signal stack on behalf of the
32 untrusted thread once the latter has switched to seccomp mode. The
33 signal stack would have to be set up when the thread is created and not
34 subsequently changed.
35* `clone()` has a `CLONE_SIGHAND` flag. By omitting this flag, trusted and
36 untrusted threads can have different sets of signal handlers. This means we
37 can opt not to set signal handlers for trusted threads.
38 * Again, per-thread signal handler sets would mean the trusted thread
39 cannot change signal handlers on behalf of untrusted threads.
40* `sigprocmask()/pthread_sigmask()`: These can be used to block signal
41 handling in trusted threads.
andybons3322f762015-08-24 21:37:0942
43## See also
andybonsad92aa32015-08-31 02:27:4444
Tom Anderson93e49e492019-12-23 19:55:3745* [LinuxCrashDumping](linux/crash_dumping.md)
andybonsad92aa32015-08-31 02:27:4446* [Issue 37728](https://crbug.com/37728)