Chromium Code Reviews| 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 <libdrm/drm.h> | |
|
mdempsky
2016/03/24 19:18:14
Why is this needed? I think it can be removed too
vignatti (out of this project)
2016/03/24 19:54:56
Done.
| |
| 8 #include <sys/ioctl.h> | 9 #include <sys/ioctl.h> |
| 9 | 10 |
| 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" |
| 13 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" | 14 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
| 14 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" | 15 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" |
| 15 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" | 16 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" |
| 16 #include "sandbox/linux/system_headers/linux_syscalls.h" | 17 #include "sandbox/linux/system_headers/linux_syscalls.h" |
| 17 | 18 |
| 18 #if defined(USE_VGEM_MAP) | |
| 19 #include <libdrm/vgem_drm.h> | |
| 20 #endif | |
| 21 | |
| 22 using sandbox::SyscallSets; | 19 using sandbox::SyscallSets; |
| 23 using sandbox::bpf_dsl::Allow; | 20 using sandbox::bpf_dsl::Allow; |
| 24 using sandbox::bpf_dsl::Arg; | 21 using sandbox::bpf_dsl::Arg; |
| 25 using sandbox::bpf_dsl::Error; | 22 using sandbox::bpf_dsl::Error; |
| 26 using sandbox::bpf_dsl::ResultExpr; | 23 using sandbox::bpf_dsl::ResultExpr; |
| 27 | 24 |
| 28 namespace content { | 25 namespace content { |
| 29 | 26 |
| 30 namespace { | 27 namespace { |
| 31 | 28 |
| 32 ResultExpr RestrictIoctl() { | 29 ResultExpr RestrictIoctl() { |
| 33 const Arg<unsigned long> request(1); | 30 const Arg<unsigned long> request(1); |
| 34 return Switch(request) | 31 return Switch(request) |
| 35 .SANDBOX_BPF_DSL_CASES((static_cast<unsigned long>(TCGETS), FIONREAD), | 32 .SANDBOX_BPF_DSL_CASES((static_cast<unsigned long>(TCGETS), FIONREAD), |
| 36 Allow()) | 33 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()); | 34 .Default(sandbox::CrashSIGSYSIoctl()); |
| 45 } | 35 } |
| 46 | 36 |
| 47 } // namespace | 37 } // namespace |
| 48 | 38 |
| 49 RendererProcessPolicy::RendererProcessPolicy() {} | 39 RendererProcessPolicy::RendererProcessPolicy() {} |
| 50 RendererProcessPolicy::~RendererProcessPolicy() {} | 40 RendererProcessPolicy::~RendererProcessPolicy() {} |
| 51 | 41 |
| 52 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { | 42 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { |
| 53 switch (sysno) { | 43 switch (sysno) { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 83 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); | 73 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); |
| 84 case __NR_prlimit64: | 74 case __NR_prlimit64: |
| 85 return Error(EPERM); // See crbug.com/160157. | 75 return Error(EPERM); // See crbug.com/160157. |
| 86 default: | 76 default: |
| 87 // Default on the content baseline policy. | 77 // Default on the content baseline policy. |
| 88 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); | 78 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); |
| 89 } | 79 } |
| 90 } | 80 } |
| 91 | 81 |
| 92 } // namespace content | 82 } // namespace content |
| OLD | NEW |