| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" | 5 #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "content/common/sandbox_linux/bpf_utility_policy_linux.h" | 27 #include "content/common/sandbox_linux/bpf_utility_policy_linux.h" |
| 28 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" | 28 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" |
| 29 #include "content/common/sandbox_linux/sandbox_linux.h" | 29 #include "content/common/sandbox_linux/sandbox_linux.h" |
| 30 #include "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h" | 30 #include "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h" |
| 31 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" | 31 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
| 32 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" | 32 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" |
| 33 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" | 33 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" |
| 34 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | 34 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
| 35 #include "sandbox/linux/services/linux_syscalls.h" | 35 #include "sandbox/linux/services/linux_syscalls.h" |
| 36 | 36 |
| 37 #if !defined(IN_NACL_HELPER) |
| 38 #include "ui/gl/gl_switches.h" |
| 39 #endif |
| 40 |
| 37 using sandbox::BaselinePolicy; | 41 using sandbox::BaselinePolicy; |
| 38 using sandbox::SandboxBPF; | 42 using sandbox::SandboxBPF; |
| 39 using sandbox::SyscallSets; | 43 using sandbox::SyscallSets; |
| 40 using sandbox::bpf_dsl::Allow; | 44 using sandbox::bpf_dsl::Allow; |
| 41 using sandbox::bpf_dsl::ResultExpr; | 45 using sandbox::bpf_dsl::ResultExpr; |
| 42 | 46 |
| 43 #else | 47 #else |
| 44 | 48 |
| 45 // Make sure that seccomp-bpf does not get disabled by mistake. Also make sure | 49 // Make sure that seccomp-bpf does not get disabled by mistake. Also make sure |
| 46 // that we think twice about this when adding a new architecture. | 50 // that we think twice about this when adding a new architecture. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 bool allow_sysv_shm = false; | 164 bool allow_sysv_shm = false; |
| 161 if (command_line.HasSwitch(switches::kGpuSandboxAllowSysVShm)) { | 165 if (command_line.HasSwitch(switches::kGpuSandboxAllowSysVShm)) { |
| 162 DCHECK(IsArchitectureArm()); | 166 DCHECK(IsArchitectureArm()); |
| 163 allow_sysv_shm = true; | 167 allow_sysv_shm = true; |
| 164 } | 168 } |
| 165 | 169 |
| 166 if (IsChromeOS() && IsArchitectureArm()) { | 170 if (IsChromeOS() && IsArchitectureArm()) { |
| 167 return scoped_ptr<SandboxBPFBasePolicy>( | 171 return scoped_ptr<SandboxBPFBasePolicy>( |
| 168 new CrosArmGpuProcessPolicy(allow_sysv_shm)); | 172 new CrosArmGpuProcessPolicy(allow_sysv_shm)); |
| 169 } else { | 173 } else { |
| 170 return scoped_ptr<SandboxBPFBasePolicy>(new GpuProcessPolicy); | 174 bool allow_mincore = command_line.HasSwitch(switches::kUseGL) && |
| 175 command_line.GetSwitchValueASCII(switches::kUseGL) == |
| 176 gfx::kGLImplementationEGLName; |
| 177 return scoped_ptr<SandboxBPFBasePolicy>( |
| 178 new GpuProcessPolicy(allow_mincore)); |
| 171 } | 179 } |
| 172 } | 180 } |
| 173 | 181 |
| 174 // Initialize the seccomp-bpf sandbox. | 182 // Initialize the seccomp-bpf sandbox. |
| 175 bool StartBPFSandbox(const base::CommandLine& command_line, | 183 bool StartBPFSandbox(const base::CommandLine& command_line, |
| 176 const std::string& process_type) { | 184 const std::string& process_type) { |
| 177 scoped_ptr<SandboxBPFBasePolicy> policy; | 185 scoped_ptr<SandboxBPFBasePolicy> policy; |
| 178 | 186 |
| 179 if (process_type == switches::kGpuProcess) { | 187 if (process_type == switches::kGpuProcess) { |
| 180 policy.reset(GetGpuProcessSandbox().release()); | 188 policy.reset(GetGpuProcessSandbox().release()); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 scoped_ptr<sandbox::bpf_dsl::SandboxBPFDSLPolicy> | 294 scoped_ptr<sandbox::bpf_dsl::SandboxBPFDSLPolicy> |
| 287 SandboxSeccompBPF::GetBaselinePolicy() { | 295 SandboxSeccompBPF::GetBaselinePolicy() { |
| 288 #if defined(USE_SECCOMP_BPF) | 296 #if defined(USE_SECCOMP_BPF) |
| 289 return scoped_ptr<sandbox::bpf_dsl::SandboxBPFDSLPolicy>(new BaselinePolicy); | 297 return scoped_ptr<sandbox::bpf_dsl::SandboxBPFDSLPolicy>(new BaselinePolicy); |
| 290 #else | 298 #else |
| 291 return scoped_ptr<sandbox::bpf_dsl::SandboxBPFDSLPolicy>(); | 299 return scoped_ptr<sandbox::bpf_dsl::SandboxBPFDSLPolicy>(); |
| 292 #endif // defined(USE_SECCOMP_BPF) | 300 #endif // defined(USE_SECCOMP_BPF) |
| 293 } | 301 } |
| 294 | 302 |
| 295 } // namespace content | 303 } // namespace content |
| OLD | NEW |