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 #if defined(OS_CHROMEOS) | |
| 9 /* | |
| 10 * TODO(vignatti): replace the local definitions below with #include | |
| 11 * <linux/dma-buf.h> once kernel version 4.6 becomes widely used. | |
|
spang
2016/03/30 21:03:24
Use C++ style comment.
This whole block should go
vignatti (out of this project)
2016/03/30 21:13:56
Done.
| |
| 12 */ | |
| 13 #include <linux/types.h> | |
| 14 | |
| 15 struct local_dma_buf_sync { | |
| 16 __u64 flags; | |
| 17 }; | |
| 18 #define LOCAL_DMA_BUF_BASE 'b' | |
| 19 #define LOCAL_DMA_BUF_IOCTL_SYNC _IOW(LOCAL_DMA_BUF_BASE, 0, struct local_d ma_buf_sync) | |
| 20 #endif | |
| 8 #include <sys/ioctl.h> | 21 #include <sys/ioctl.h> |
| 9 | 22 |
| 10 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 11 #include "content/common/sandbox_linux/sandbox_linux.h" | 24 #include "content/common/sandbox_linux/sandbox_linux.h" |
| 12 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" | 25 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" |
| 13 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" | 26 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
| 14 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" | 27 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" |
| 15 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" | 28 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" |
| 16 #include "sandbox/linux/system_headers/linux_syscalls.h" | 29 #include "sandbox/linux/system_headers/linux_syscalls.h" |
| 17 | 30 |
| 18 using sandbox::SyscallSets; | 31 using sandbox::SyscallSets; |
| 19 using sandbox::bpf_dsl::Allow; | 32 using sandbox::bpf_dsl::Allow; |
| 20 using sandbox::bpf_dsl::Arg; | 33 using sandbox::bpf_dsl::Arg; |
| 21 using sandbox::bpf_dsl::Error; | 34 using sandbox::bpf_dsl::Error; |
| 22 using sandbox::bpf_dsl::ResultExpr; | 35 using sandbox::bpf_dsl::ResultExpr; |
| 23 | 36 |
| 24 namespace content { | 37 namespace content { |
| 25 | 38 |
| 26 namespace { | 39 namespace { |
| 27 | 40 |
| 28 ResultExpr RestrictIoctl() { | 41 ResultExpr RestrictIoctl() { |
| 29 const Arg<unsigned long> request(1); | 42 const Arg<unsigned long> request(1); |
| 30 return Switch(request) | 43 return Switch(request) |
| 31 .SANDBOX_BPF_DSL_CASES((static_cast<unsigned long>(TCGETS), FIONREAD), | 44 .SANDBOX_BPF_DSL_CASES((static_cast<unsigned long>(TCGETS), FIONREAD), |
| 32 Allow()) | 45 Allow()) |
| 46 #if defined(OS_CHROMEOS) | |
| 47 .SANDBOX_BPF_DSL_CASES((static_cast<unsigned long>(LOCAL_DMA_BUF_IOCTL_SYN C)), | |
| 48 Allow()) | |
| 49 #endif | |
| 33 .Default(sandbox::CrashSIGSYSIoctl()); | 50 .Default(sandbox::CrashSIGSYSIoctl()); |
| 34 } | 51 } |
| 35 | 52 |
| 36 } // namespace | 53 } // namespace |
| 37 | 54 |
| 38 RendererProcessPolicy::RendererProcessPolicy() {} | 55 RendererProcessPolicy::RendererProcessPolicy() {} |
| 39 RendererProcessPolicy::~RendererProcessPolicy() {} | 56 RendererProcessPolicy::~RendererProcessPolicy() {} |
| 40 | 57 |
| 41 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { | 58 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { |
| 42 switch (sysno) { | 59 switch (sysno) { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 72 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); | 89 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); |
| 73 case __NR_prlimit64: | 90 case __NR_prlimit64: |
| 74 return Error(EPERM); // See crbug.com/160157. | 91 return Error(EPERM); // See crbug.com/160157. |
| 75 default: | 92 default: |
| 76 // Default on the content baseline policy. | 93 // Default on the content baseline policy. |
| 77 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); | 94 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); |
| 78 } | 95 } |
| 79 } | 96 } |
| 80 | 97 |
| 81 } // namespace content | 98 } // namespace content |
| OLD | NEW |