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 #include <sys/ioctl.h> |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "content/common/sandbox_linux/sandbox_linux.h" | 11 #include "content/common/sandbox_linux/sandbox_linux.h" |
12 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" | 12 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" |
13 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" | 13 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
14 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" | 14 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" |
15 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" | 15 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" |
16 #include "sandbox/linux/system_headers/linux_syscalls.h" | 16 #include "sandbox/linux/system_headers/linux_syscalls.h" |
17 | 17 |
18 #if defined(USE_VGEM_MAP) | |
19 #include <libdrm/vgem_drm.h> | |
20 #endif | |
21 | |
22 using sandbox::SyscallSets; | 18 using sandbox::SyscallSets; |
23 using sandbox::bpf_dsl::Allow; | 19 using sandbox::bpf_dsl::Allow; |
24 using sandbox::bpf_dsl::Arg; | 20 using sandbox::bpf_dsl::Arg; |
25 using sandbox::bpf_dsl::Error; | 21 using sandbox::bpf_dsl::Error; |
26 using sandbox::bpf_dsl::ResultExpr; | 22 using sandbox::bpf_dsl::ResultExpr; |
27 | 23 |
28 namespace content { | 24 namespace content { |
29 | 25 |
30 namespace { | 26 namespace { |
31 | 27 |
32 ResultExpr RestrictIoctl() { | 28 ResultExpr RestrictIoctl() { |
33 const Arg<unsigned long> request(1); | 29 const Arg<unsigned long> request(1); |
34 return Switch(request) | 30 return Switch(request) |
35 .SANDBOX_BPF_DSL_CASES((static_cast<unsigned long>(TCGETS), FIONREAD), | 31 .SANDBOX_BPF_DSL_CASES((static_cast<unsigned long>(TCGETS), FIONREAD), |
36 Allow()) | 32 Allow()) |
37 #if defined(USE_VGEM_MAP) | |
38 // Type of DRM_IOCTL_XXX is unsigned long on IA and unsigned int on ARM. | |
39 .SANDBOX_BPF_DSL_CASES( | |
40 (static_cast<unsigned long>(DRM_IOCTL_GEM_CLOSE), | |
41 DRM_IOCTL_VGEM_MODE_MAP_DUMB, DRM_IOCTL_PRIME_FD_TO_HANDLE), | |
42 Allow()) | |
43 #endif | |
44 .Default(sandbox::CrashSIGSYSIoctl()); | 33 .Default(sandbox::CrashSIGSYSIoctl()); |
45 } | 34 } |
46 | 35 |
47 } // namespace | 36 } // namespace |
48 | 37 |
49 RendererProcessPolicy::RendererProcessPolicy() {} | 38 RendererProcessPolicy::RendererProcessPolicy() {} |
50 RendererProcessPolicy::~RendererProcessPolicy() {} | 39 RendererProcessPolicy::~RendererProcessPolicy() {} |
51 | 40 |
52 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { | 41 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { |
53 switch (sysno) { | 42 switch (sysno) { |
(...skipping 29 matching lines...) Expand all Loading... |
83 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); | 72 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); |
84 case __NR_prlimit64: | 73 case __NR_prlimit64: |
85 return Error(EPERM); // See crbug.com/160157. | 74 return Error(EPERM); // See crbug.com/160157. |
86 default: | 75 default: |
87 // Default on the content baseline policy. | 76 // Default on the content baseline policy. |
88 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); | 77 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); |
89 } | 78 } |
90 } | 79 } |
91 | 80 |
92 } // namespace content | 81 } // namespace content |
OLD | NEW |