Chromium Code Reviews| Index: content/common/sandbox_seccomp_bpf_linux.cc |
| diff --git a/content/common/sandbox_seccomp_bpf_linux.cc b/content/common/sandbox_seccomp_bpf_linux.cc |
| index 7051acb93a65132ee1048a72682e456d9bb06231..4d222bb0b0396c01bd0a3c2b59c34fd896d4d3c0 100644 |
| --- a/content/common/sandbox_seccomp_bpf_linux.cc |
| +++ b/content/common/sandbox_seccomp_bpf_linux.cc |
| @@ -101,6 +101,21 @@ intptr_t CrashSIGSYS_Handler(const struct arch_seccomp_data& args, void* aux) { |
| _exit(1); |
| } |
| +// TODO(jln): rewrite reporting functions. |
| +intptr_t ReportCloneFailure(const struct arch_seccomp_data& args, void* aux) { |
| + // "flags" in the first argument in the kernel's clone(). |
| + // Mark as volatile to be able to find the value on the stack in a minidump. |
| + volatile uint64_t clone_flags = args.args[0]; |
| + volatile char* addr = |
| + reinterpret_cast<volatile char*>(clone_flags & 0xFFFFFF); |
| + *addr = '\0'; |
| + // Hit the NULL page if this fails. |
|
Chris Evans
2013/02/06 03:44:54
Nit: "fails to fault"?
jln (very slow on Chromium)
2013/02/06 04:00:51
Done.
|
| + addr = reinterpret_cast<volatile char*>(clone_flags & 0xFFF); |
| + *addr = '\0'; |
| + for (;;) |
| + _exit(1); |
| +} |
| + |
| bool IsAcceleratedVideoDecodeEnabled() { |
| // Accelerated video decode is currently enabled on Chrome OS, |
| // but not on Linux: crbug.com/137247. |
| @@ -1236,8 +1251,23 @@ ErrorCode GpuBrokerProcessPolicy(int sysno, void*) { |
| } |
| } |
| +// Allow clone for threads, crash if anything else is attempted. |
| +ErrorCode RestrictCloneToThreads() { |
| + // Glibc's pthread. |
| + return Sandbox::Cond(0, ErrorCode::TP_32BIT, ErrorCode::OP_EQUAL, |
| + CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | |
| + CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS | |
| + CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID, |
| + ErrorCode(ErrorCode::ERR_ALLOWED), |
| + Sandbox::Trap(ReportCloneFailure, NULL)); |
| +} |
| + |
| ErrorCode RendererOrWorkerProcessPolicy(int sysno, void *) { |
| switch (sysno) { |
| + case __NR_clone: |
| +#if defined(__x86_64__) |
|
Chris Evans
2013/02/06 03:44:54
Nit: add TODO(jln) for other platforms?
|
| + return RestrictCloneToThreads(); |
| +#endif |
| case __NR_ioctl: // TODO(jln) investigate legitimate use in the renderer |
| // and see if alternatives can be used. |
| case __NR_fdatasync: |