[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / content / common / sandbox_linux / bpf_utility_policy_linux.cc
blob12207b8ac2ae9b8debee52516dd7ed253ccce244
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/common/sandbox_linux/bpf_utility_policy_linux.h"
7 #include <errno.h>
9 #include "base/basictypes.h"
10 #include "build/build_config.h"
11 #include "content/common/sandbox_linux/sandbox_linux.h"
12 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h"
13 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h"
14 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_policy.h"
15 #include "sandbox/linux/services/linux_syscalls.h"
17 using sandbox::SyscallSets;
19 namespace content {
21 UtilityProcessPolicy::UtilityProcessPolicy() {
23 UtilityProcessPolicy::~UtilityProcessPolicy() {
26 ErrorCode UtilityProcessPolicy::EvaluateSyscall(SandboxBPF* sandbox,
27 int sysno) const {
28 // TODO(mdempsky): For now, this is just a copy of the renderer
29 // policy, which happens to work well for utility processes too. It
30 // should be possible to limit further though. In particular, the
31 // entries below annotated with bug references are most likely
32 // unnecessary.
34 switch (sysno) {
35 case __NR_ioctl:
36 return sandbox::RestrictIoctl(sandbox);
37 // Allow the system calls below.
38 // The baseline policy allows __NR_clock_gettime. Allow
39 // clock_getres() for V8. crbug.com/329053.
40 case __NR_clock_getres:
41 case __NR_fdatasync:
42 case __NR_fsync:
43 case __NR_getpriority:
44 #if defined(__i386__) || defined(__x86_64__)
45 case __NR_getrlimit:
46 #endif
47 #if defined(__i386__) || defined(__arm__)
48 case __NR_ugetrlimit:
49 #endif
50 case __NR_mremap: // See crbug.com/149834.
51 case __NR_pread64:
52 case __NR_pwrite64:
53 case __NR_sched_getaffinity:
54 case __NR_sched_get_priority_max:
55 case __NR_sched_get_priority_min:
56 case __NR_sched_getparam:
57 case __NR_sched_getscheduler:
58 case __NR_sched_setscheduler:
59 case __NR_setpriority:
60 case __NR_sysinfo:
61 case __NR_times:
62 case __NR_uname:
63 return ErrorCode(ErrorCode::ERR_ALLOWED);
64 case __NR_prlimit64:
65 return ErrorCode(EPERM); // See crbug.com/160157.
66 default:
67 // Default on the content baseline policy.
68 return SandboxBPFBasePolicy::EvaluateSyscall(sandbox, sysno);
72 } // namespace content