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_ppapi_policy_linux.h" | 5 #include "content/common/sandbox_linux/bpf_ppapi_policy_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
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/seccomp-bpf-helpers/syscall_parameters_restrictions.h" | 12 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" |
13 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" | 13 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" |
14 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_policy.h" | 14 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_policy.h" |
15 #include "sandbox/linux/services/linux_syscalls.h" | 15 #include "sandbox/linux/services/linux_syscalls.h" |
16 | 16 |
17 using sandbox::SyscallSets; | 17 using sandbox::SyscallSets; |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 namespace { | |
22 | |
23 inline bool IsUsingToolKitGtk() { | |
24 #if defined(TOOLKIT_GTK) | |
25 return true; | |
26 #else | |
27 return false; | |
28 #endif | |
29 } | |
30 | |
31 } // namespace | |
32 | |
33 PpapiProcessPolicy::PpapiProcessPolicy() {} | 21 PpapiProcessPolicy::PpapiProcessPolicy() {} |
34 PpapiProcessPolicy::~PpapiProcessPolicy() {} | 22 PpapiProcessPolicy::~PpapiProcessPolicy() {} |
35 | 23 |
36 ErrorCode PpapiProcessPolicy::EvaluateSyscall(SandboxBPF* sandbox, | 24 ErrorCode PpapiProcessPolicy::EvaluateSyscall(SandboxBPF* sandbox, |
37 int sysno) const { | 25 int sysno) const { |
38 switch (sysno) { | 26 switch (sysno) { |
39 case __NR_clone: | 27 case __NR_clone: |
40 return sandbox::RestrictCloneToThreadsAndEPERMFork(sandbox); | 28 return sandbox::RestrictCloneToThreadsAndEPERMFork(sandbox); |
41 case __NR_pread64: | 29 case __NR_pread64: |
42 case __NR_pwrite64: | 30 case __NR_pwrite64: |
43 case __NR_sched_get_priority_max: | 31 case __NR_sched_get_priority_max: |
44 case __NR_sched_get_priority_min: | 32 case __NR_sched_get_priority_min: |
45 case __NR_sched_getaffinity: | 33 case __NR_sched_getaffinity: |
46 case __NR_sched_getparam: | 34 case __NR_sched_getparam: |
47 case __NR_sched_getscheduler: | 35 case __NR_sched_getscheduler: |
48 case __NR_sched_setscheduler: | 36 case __NR_sched_setscheduler: |
49 case __NR_times: | 37 case __NR_times: |
50 return ErrorCode(ErrorCode::ERR_ALLOWED); | 38 return ErrorCode(ErrorCode::ERR_ALLOWED); |
51 case __NR_ioctl: | 39 case __NR_ioctl: |
52 return ErrorCode(ENOTTY); // Flash Access. | 40 return ErrorCode(ENOTTY); // Flash Access. |
53 default: | 41 default: |
54 if (IsUsingToolKitGtk()) { | |
55 #if defined(__x86_64__) || defined(__arm__) | |
56 if (SyscallSets::IsSystemVSharedMemory(sysno)) | |
57 return ErrorCode(ErrorCode::ERR_ALLOWED); | |
58 #endif | |
59 #if defined(__i386__) | |
60 if (SyscallSets::IsSystemVIpc(sysno)) | |
61 return ErrorCode(ErrorCode::ERR_ALLOWED); | |
62 #endif | |
63 } | |
64 | |
65 // Default on the baseline policy. | 42 // Default on the baseline policy. |
66 return SandboxBPFBasePolicy::EvaluateSyscall(sandbox, sysno); | 43 return SandboxBPFBasePolicy::EvaluateSyscall(sandbox, sysno); |
67 } | 44 } |
68 } | 45 } |
69 | 46 |
70 } // namespace content | 47 } // namespace content |
OLD | NEW |