OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/bpf_renderer_policy_linux.h" | 5 #include "content/common/sandbox_linux/bpf_renderer_policy_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sys/ioctl.h> |
8 | 9 |
9 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
11 #include "content/common/sandbox_linux/sandbox_linux.h" | 12 #include "content/common/sandbox_linux/sandbox_linux.h" |
12 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" | 13 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" |
| 14 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
13 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" | 15 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" |
14 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" | 16 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" |
15 #include "sandbox/linux/system_headers/linux_syscalls.h" | 17 #include "sandbox/linux/system_headers/linux_syscalls.h" |
16 | 18 |
| 19 #if defined(USE_VGEM_MAP) |
| 20 #include <libdrm/vgem_drm.h> |
| 21 #endif |
| 22 |
17 using sandbox::SyscallSets; | 23 using sandbox::SyscallSets; |
18 using sandbox::bpf_dsl::Allow; | 24 using sandbox::bpf_dsl::Allow; |
| 25 using sandbox::bpf_dsl::Arg; |
19 using sandbox::bpf_dsl::Error; | 26 using sandbox::bpf_dsl::Error; |
20 using sandbox::bpf_dsl::ResultExpr; | 27 using sandbox::bpf_dsl::ResultExpr; |
21 | 28 |
22 namespace content { | 29 namespace content { |
23 | 30 |
| 31 namespace { |
| 32 |
| 33 ResultExpr RestrictIoctl() { |
| 34 const Arg<unsigned long> request(1); |
| 35 return Switch(request) |
| 36 .SANDBOX_BPF_DSL_CASES((static_cast<unsigned long>(TCGETS), FIONREAD), |
| 37 Allow()) |
| 38 #if defined(USE_VGEM_MAP) |
| 39 // Type of DRM_IOCTL_XXX is unsigned long on IA and unsigned int on ARM. |
| 40 .SANDBOX_BPF_DSL_CASES( |
| 41 (static_cast<unsigned long>(DRM_IOCTL_GEM_CLOSE), |
| 42 DRM_IOCTL_VGEM_MODE_MAP_DUMB, DRM_IOCTL_PRIME_FD_TO_HANDLE), |
| 43 Allow()) |
| 44 #endif |
| 45 .Default(sandbox::CrashSIGSYSIoctl()); |
| 46 } |
| 47 |
| 48 } // namespace |
| 49 |
24 RendererProcessPolicy::RendererProcessPolicy() {} | 50 RendererProcessPolicy::RendererProcessPolicy() {} |
25 RendererProcessPolicy::~RendererProcessPolicy() {} | 51 RendererProcessPolicy::~RendererProcessPolicy() {} |
26 | 52 |
27 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { | 53 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { |
28 switch (sysno) { | 54 switch (sysno) { |
29 // The baseline policy allows __NR_clock_gettime. Allow | 55 // The baseline policy allows __NR_clock_gettime. Allow |
30 // clock_getres() for V8. crbug.com/329053. | 56 // clock_getres() for V8. crbug.com/329053. |
31 case __NR_clock_getres: | 57 case __NR_clock_getres: |
32 return sandbox::RestrictClockID(); | 58 return sandbox::RestrictClockID(); |
33 case __NR_ioctl: | 59 case __NR_ioctl: |
34 return sandbox::RestrictIoctl(); | 60 return RestrictIoctl(); |
35 // Allow the system calls below. | 61 // Allow the system calls below. |
36 case __NR_fdatasync: | 62 case __NR_fdatasync: |
37 case __NR_fsync: | 63 case __NR_fsync: |
38 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) | 64 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) |
39 case __NR_getrlimit: | 65 case __NR_getrlimit: |
40 #endif | 66 #endif |
41 #if defined(__i386__) || defined(__arm__) | 67 #if defined(__i386__) || defined(__arm__) |
42 case __NR_ugetrlimit: | 68 case __NR_ugetrlimit: |
43 #endif | 69 #endif |
44 case __NR_mremap: // See crbug.com/149834. | 70 case __NR_mremap: // See crbug.com/149834. |
(...skipping 12 matching lines...) Expand all Loading... |
57 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); | 83 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); |
58 case __NR_prlimit64: | 84 case __NR_prlimit64: |
59 return Error(EPERM); // See crbug.com/160157. | 85 return Error(EPERM); // See crbug.com/160157. |
60 default: | 86 default: |
61 // Default on the content baseline policy. | 87 // Default on the content baseline policy. |
62 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); | 88 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); |
63 } | 89 } |
64 } | 90 } |
65 | 91 |
66 } // namespace content | 92 } // namespace content |
OLD | NEW |