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 <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(OS_CHROMEOS) | |
| 19 // TODO(vignatti): replace the local definitions below with #include | |
| 20 // <linux/dma-buf.h> once kernel version 4.6 becomes widely used. | |
| 21 #include <linux/types.h> | |
| 22 | |
| 23 struct local_dma_buf_sync { | |
| 24 __u64 flags; | |
| 25 }; | |
| 26 #define LOCAL_DMA_BUF_BASE 'b' | |
| 27 #define LOCAL_DMA_BUF_IOCTL_SYNC _IOW(LOCAL_DMA_BUF_BASE, 0, struct local_d ma_buf_sync) | |
|
Robert Sesek
2016/04/04 18:12:17
Please wrap to 80 columns, and on line 46.
| |
| 28 #endif | |
| 29 | |
| 18 using sandbox::SyscallSets; | 30 using sandbox::SyscallSets; |
| 19 using sandbox::bpf_dsl::Allow; | 31 using sandbox::bpf_dsl::Allow; |
| 20 using sandbox::bpf_dsl::Arg; | 32 using sandbox::bpf_dsl::Arg; |
| 21 using sandbox::bpf_dsl::Error; | 33 using sandbox::bpf_dsl::Error; |
| 22 using sandbox::bpf_dsl::ResultExpr; | 34 using sandbox::bpf_dsl::ResultExpr; |
| 23 | 35 |
| 24 namespace content { | 36 namespace content { |
| 25 | 37 |
| 26 namespace { | 38 namespace { |
| 27 | 39 |
| 28 ResultExpr RestrictIoctl() { | 40 ResultExpr RestrictIoctl() { |
| 29 const Arg<unsigned long> request(1); | 41 const Arg<unsigned long> request(1); |
| 30 return Switch(request) | 42 return Switch(request) |
| 31 .SANDBOX_BPF_DSL_CASES((static_cast<unsigned long>(TCGETS), FIONREAD), | 43 .SANDBOX_BPF_DSL_CASES((static_cast<unsigned long>(TCGETS), FIONREAD), |
| 32 Allow()) | 44 Allow()) |
| 45 #if defined(OS_CHROMEOS) | |
| 46 .SANDBOX_BPF_DSL_CASES((static_cast<unsigned long>(LOCAL_DMA_BUF_IOCTL_SYN C)), | |
| 47 Allow()) | |
| 48 #endif | |
| 33 .Default(sandbox::CrashSIGSYSIoctl()); | 49 .Default(sandbox::CrashSIGSYSIoctl()); |
| 34 } | 50 } |
| 35 | 51 |
| 36 } // namespace | 52 } // namespace |
| 37 | 53 |
| 38 RendererProcessPolicy::RendererProcessPolicy() {} | 54 RendererProcessPolicy::RendererProcessPolicy() {} |
| 39 RendererProcessPolicy::~RendererProcessPolicy() {} | 55 RendererProcessPolicy::~RendererProcessPolicy() {} |
| 40 | 56 |
| 41 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { | 57 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { |
| 42 switch (sysno) { | 58 switch (sysno) { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 72 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); | 88 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); |
| 73 case __NR_prlimit64: | 89 case __NR_prlimit64: |
| 74 return Error(EPERM); // See crbug.com/160157. | 90 return Error(EPERM); // See crbug.com/160157. |
| 75 default: | 91 default: |
| 76 // Default on the content baseline policy. | 92 // Default on the content baseline policy. |
| 77 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); | 93 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); |
| 78 } | 94 } |
| 79 } | 95 } |
| 80 | 96 |
| 81 } // namespace content | 97 } // namespace content |
| OLD | NEW |