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( |
| 37 (static_cast<unsigned long>(TCGETS), FIONREAD), Allow()) |
| 38 #if defined(USE_VGEM_MAP) |
| 39 .SANDBOX_BPF_DSL_CASES((DRM_IOCTL_GEM_CLOSE, DRM_IOCTL_VGEM_MODE_MAP_DUMB, |
| 40 DRM_IOCTL_PRIME_FD_TO_HANDLE), |
| 41 Allow()) |
| 42 #endif |
| 43 .Default(sandbox::CrashSIGSYSIoctl()); |
| 44 } |
| 45 |
| 46 } // namespace |
| 47 |
24 RendererProcessPolicy::RendererProcessPolicy() {} | 48 RendererProcessPolicy::RendererProcessPolicy() {} |
25 RendererProcessPolicy::~RendererProcessPolicy() {} | 49 RendererProcessPolicy::~RendererProcessPolicy() {} |
26 | 50 |
27 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { | 51 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { |
28 switch (sysno) { | 52 switch (sysno) { |
29 // The baseline policy allows __NR_clock_gettime. Allow | 53 // The baseline policy allows __NR_clock_gettime. Allow |
30 // clock_getres() for V8. crbug.com/329053. | 54 // clock_getres() for V8. crbug.com/329053. |
31 case __NR_clock_getres: | 55 case __NR_clock_getres: |
32 return sandbox::RestrictClockID(); | 56 return sandbox::RestrictClockID(); |
33 case __NR_ioctl: | 57 case __NR_ioctl: |
34 return sandbox::RestrictIoctl(); | 58 return RestrictIoctl(); |
35 // Allow the system calls below. | 59 // Allow the system calls below. |
36 case __NR_fdatasync: | 60 case __NR_fdatasync: |
37 case __NR_fsync: | 61 case __NR_fsync: |
38 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) | 62 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) |
39 case __NR_getrlimit: | 63 case __NR_getrlimit: |
40 #endif | 64 #endif |
41 #if defined(__i386__) || defined(__arm__) | 65 #if defined(__i386__) || defined(__arm__) |
42 case __NR_ugetrlimit: | 66 case __NR_ugetrlimit: |
43 #endif | 67 #endif |
44 case __NR_mremap: // See crbug.com/149834. | 68 case __NR_mremap: // See crbug.com/149834. |
(...skipping 12 matching lines...) Expand all Loading... |
57 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); | 81 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); |
58 case __NR_prlimit64: | 82 case __NR_prlimit64: |
59 return Error(EPERM); // See crbug.com/160157. | 83 return Error(EPERM); // See crbug.com/160157. |
60 default: | 84 default: |
61 // Default on the content baseline policy. | 85 // Default on the content baseline policy. |
62 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); | 86 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); |
63 } | 87 } |
64 } | 88 } |
65 | 89 |
66 } // namespace content | 90 } // namespace content |
OLD | NEW |