| Index: content/common/sandbox_init_linux.cc
|
| diff --git a/content/common/sandbox_init_linux.cc b/content/common/sandbox_init_linux.cc
|
| index a67a784232aa70bcd6c856baf2546384bbab83da..dc01725e77aaf66f455c1841d2a18eb8165f858d 100644
|
| --- a/content/common/sandbox_init_linux.cc
|
| +++ b/content/common/sandbox_init_linux.cc
|
| @@ -56,6 +56,10 @@
|
|
|
| #endif
|
|
|
| +using playground2::arch_seccomp_data;
|
| +using playground2::ErrorCode;
|
| +using playground2::Sandbox;
|
| +
|
| namespace {
|
|
|
| bool IsSingleThreaded() {
|
| @@ -216,7 +220,7 @@ intptr_t GpuOpenSIGSYS_Handler(const struct arch_seccomp_data& args,
|
|
|
| #if defined(__x86_64__)
|
| // x86_64 only because it references system calls that are multiplexed on IA32.
|
| -playground2::Sandbox::ErrorCode GpuProcessPolicy_x86_64(int sysno) {
|
| +ErrorCode GpuProcessPolicy_x86_64(int sysno) {
|
| switch(sysno) {
|
| case __NR_read:
|
| case __NR_ioctl:
|
| @@ -264,33 +268,33 @@ playground2::Sandbox::ErrorCode GpuProcessPolicy_x86_64(int sysno) {
|
| case __NR_getppid: // ATI binary driver.
|
| case __NR_shutdown: // Virtual driver.
|
| case __NR_rt_sigaction: // Breakpad signal handler.
|
| - return playground2::Sandbox::SB_ALLOWED;
|
| + return ErrorCode(ErrorCode::ERR_ALLOWED);
|
| case __NR_socket:
|
| - return EACCES; // Nvidia binary driver.
|
| + return ErrorCode(EACCES); // Nvidia binary driver.
|
| case __NR_fchmod:
|
| - return EPERM; // ATI binary driver.
|
| + return ErrorCode(EPERM); // ATI binary driver.
|
| case __NR_open:
|
| // Hook open() in the GPU process to allow opening /etc/drirc,
|
| // needed by Mesa.
|
| // The hook needs dup(), lseek(), and close() to be allowed.
|
| - return playground2::Sandbox::ErrorCode(GpuOpenSIGSYS_Handler, NULL);
|
| + return Sandbox::Trap(GpuOpenSIGSYS_Handler, NULL);
|
| default:
|
| if (IsGettimeSyscall(sysno) ||
|
| IsKillSyscall(sysno)) { // GPU watchdog.
|
| - return playground2::Sandbox::SB_ALLOWED;
|
| + return ErrorCode(ErrorCode::ERR_ALLOWED);
|
| }
|
| // Generally, filename-based syscalls will fail with ENOENT to behave
|
| // similarly to a possible future setuid sandbox.
|
| if (IsFileSystemSyscall(sysno)) {
|
| - return ENOENT;
|
| + return ErrorCode(ENOENT);
|
| }
|
| // In any other case crash the program with our SIGSYS handler
|
| - return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL);
|
| + return Sandbox::Trap(CrashSIGSYS_Handler, NULL);
|
| }
|
| }
|
|
|
| // x86_64 only because it references system calls that are multiplexed on IA32.
|
| -playground2::Sandbox::ErrorCode FlashProcessPolicy_x86_64(int sysno) {
|
| +ErrorCode FlashProcessPolicy_x86_64(int sysno) {
|
| switch (sysno) {
|
| case __NR_futex:
|
| case __NR_write:
|
| @@ -336,31 +340,31 @@ playground2::Sandbox::ErrorCode FlashProcessPolicy_x86_64(int sysno) {
|
| case __NR_shmctl:
|
| case __NR_shmat:
|
| case __NR_shmdt:
|
| - return playground2::Sandbox::SB_ALLOWED;
|
| + return ErrorCode(ErrorCode::ERR_ALLOWED);
|
| case __NR_ioctl:
|
| - return ENOTTY; // Flash Access.
|
| + return ErrorCode(ENOTTY); // Flash Access.
|
| case __NR_socket:
|
| - return EACCES;
|
| + return ErrorCode(EACCES);
|
|
|
| default:
|
| if (IsGettimeSyscall(sysno) ||
|
| IsKillSyscall(sysno)) {
|
| - return playground2::Sandbox::SB_ALLOWED;
|
| + return ErrorCode(ErrorCode::ERR_ALLOWED);
|
| }
|
| if (IsFileSystemSyscall(sysno)) {
|
| - return ENOENT;
|
| + return ErrorCode(ENOENT);
|
| }
|
| // In any other case crash the program with our SIGSYS handler.
|
| - return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL);
|
| + return Sandbox::Trap(CrashSIGSYS_Handler, NULL);
|
| }
|
| }
|
| #endif
|
|
|
| -playground2::Sandbox::ErrorCode BlacklistPtracePolicy(int sysno) {
|
| +ErrorCode BlacklistPtracePolicy(int sysno) {
|
| if (sysno < static_cast<int>(MIN_SYSCALL) ||
|
| sysno > static_cast<int>(MAX_SYSCALL)) {
|
| // TODO(jln) we should not have to do that in a trivial policy.
|
| - return ENOSYS;
|
| + return ErrorCode(ENOSYS);
|
| }
|
| switch (sysno) {
|
| case __NR_ptrace:
|
| @@ -368,27 +372,27 @@ playground2::Sandbox::ErrorCode BlacklistPtracePolicy(int sysno) {
|
| case __NR_process_vm_writev:
|
| case __NR_migrate_pages:
|
| case __NR_move_pages:
|
| - return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL);
|
| + return Sandbox::Trap(CrashSIGSYS_Handler, NULL);
|
| default:
|
| - return playground2::Sandbox::SB_ALLOWED;
|
| + return ErrorCode(ErrorCode::ERR_ALLOWED);
|
| }
|
| }
|
|
|
| // Allow all syscalls.
|
| // This will still deny x32 or IA32 calls in 64 bits mode or
|
| // 64 bits system calls in compatibility mode.
|
| -playground2::Sandbox::ErrorCode AllowAllPolicy(int sysno) {
|
| +ErrorCode AllowAllPolicy(int sysno) {
|
| if (sysno < static_cast<int>(MIN_SYSCALL) ||
|
| sysno > static_cast<int>(MAX_SYSCALL)) {
|
| // TODO(jln) we should not have to do that in a trivial policy.
|
| - return ENOSYS;
|
| + return ErrorCode(ENOSYS);
|
| } else {
|
| - return playground2::Sandbox::SB_ALLOWED;
|
| + return ErrorCode(ErrorCode::ERR_ALLOWED);
|
| }
|
| }
|
|
|
| // Warms up/preloads resources needed by the policies.
|
| -void WarmupPolicy(playground2::Sandbox::EvaluateSyscall policy) {
|
| +void WarmupPolicy(Sandbox::EvaluateSyscall policy) {
|
| #if defined(__x86_64__)
|
| if (policy == GpuProcessPolicy_x86_64)
|
| OpenWithCache(kDriRcPath, O_RDONLY);
|
| @@ -426,7 +430,7 @@ bool ShouldDisableSandbox(const CommandLine& command_line,
|
| return false;
|
| }
|
|
|
| -playground2::Sandbox::EvaluateSyscall GetProcessSyscallPolicy(
|
| +Sandbox::EvaluateSyscall GetProcessSyscallPolicy(
|
| const CommandLine& command_line,
|
| const std::string& process_type) {
|
| #if defined(__x86_64__)
|
| @@ -495,19 +499,19 @@ void InitializeSandbox_x86() {
|
| // have a /proc fd and pass it here.
|
| // Passing -1 as the /proc fd since we have no special way to have it for
|
| // now.
|
| - if (playground2::Sandbox::supportsSeccompSandbox(-1) !=
|
| - playground2::Sandbox::STATUS_AVAILABLE) {
|
| + if (Sandbox::supportsSeccompSandbox(-1) !=
|
| + Sandbox::STATUS_AVAILABLE) {
|
| return;
|
| }
|
|
|
| - playground2::Sandbox::EvaluateSyscall SyscallPolicy =
|
| + Sandbox::EvaluateSyscall SyscallPolicy =
|
| GetProcessSyscallPolicy(command_line, process_type);
|
|
|
| // Warms up resources needed by the policy we're about to enable.
|
| WarmupPolicy(SyscallPolicy);
|
|
|
| - playground2::Sandbox::setSandboxPolicy(SyscallPolicy, NULL);
|
| - playground2::Sandbox::startSandbox();
|
| + Sandbox::setSandboxPolicy(SyscallPolicy, NULL);
|
| + Sandbox::startSandbox();
|
|
|
| // TODO(jorgelo): remove this once we surface
|
| // seccomp filter sandbox status in about:sandbox.
|
|
|