Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: content/common/sandbox_linux/bpf_renderer_policy_linux.cc

Issue 299683004: Rewrite all BPF policies to use DSL API Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Overhaul of DSL and implementation Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 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/bpf_dsl.h"
12 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" 13 #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-helpers/syscall_sets.h"
14 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_policy.h" 15 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_policy.h"
15 #include "sandbox/linux/services/linux_syscalls.h" 16 #include "sandbox/linux/services/linux_syscalls.h"
16 17
18 using namespace sandbox::bpf_dsl;
17 using sandbox::SyscallSets; 19 using sandbox::SyscallSets;
18 20
19 namespace content { 21 namespace content {
20 22
21 RendererProcessPolicy::RendererProcessPolicy() {} 23 RendererProcessPolicy::RendererProcessPolicy() {}
22 RendererProcessPolicy::~RendererProcessPolicy() {} 24 RendererProcessPolicy::~RendererProcessPolicy() {}
23 25
24 ErrorCode RendererProcessPolicy::EvaluateSyscall(SandboxBPF* sandbox, 26 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const {
25 int sysno) const {
26 switch (sysno) { 27 switch (sysno) {
27 case __NR_ioctl: 28 case __NR_ioctl:
28 return sandbox::RestrictIoctl(sandbox); 29 return sandbox::RestrictIoctl();
29 case __NR_prctl: 30 case __NR_prctl:
30 return sandbox::RestrictPrctl(sandbox); 31 return sandbox::RestrictPrctl();
31 // Allow the system calls below. 32 // Allow the system calls below.
32 // The baseline policy allows __NR_clock_gettime. Allow 33 // The baseline policy allows __NR_clock_gettime. Allow
33 // clock_getres() for V8. crbug.com/329053. 34 // clock_getres() for V8. crbug.com/329053.
34 case __NR_clock_getres: 35 case __NR_clock_getres:
35 case __NR_fdatasync: 36 case __NR_fdatasync:
36 case __NR_fsync: 37 case __NR_fsync:
37 case __NR_getpriority: 38 case __NR_getpriority:
38 #if defined(__i386__) || defined(__x86_64__) 39 #if defined(__i386__) || defined(__x86_64__)
39 case __NR_getrlimit: 40 case __NR_getrlimit:
40 #endif 41 #endif
41 #if defined(__i386__) || defined(__arm__) 42 #if defined(__i386__) || defined(__arm__)
42 case __NR_ugetrlimit: 43 case __NR_ugetrlimit:
43 #endif 44 #endif
44 case __NR_mremap: // See crbug.com/149834. 45 case __NR_mremap: // See crbug.com/149834.
45 case __NR_pread64: 46 case __NR_pread64:
46 case __NR_pwrite64: 47 case __NR_pwrite64:
47 case __NR_sched_getaffinity: 48 case __NR_sched_getaffinity:
48 case __NR_sched_get_priority_max: 49 case __NR_sched_get_priority_max:
49 case __NR_sched_get_priority_min: 50 case __NR_sched_get_priority_min:
50 case __NR_sched_getparam: 51 case __NR_sched_getparam:
51 case __NR_sched_getscheduler: 52 case __NR_sched_getscheduler:
52 case __NR_sched_setscheduler: 53 case __NR_sched_setscheduler:
53 case __NR_setpriority: 54 case __NR_setpriority:
54 case __NR_sysinfo: 55 case __NR_sysinfo:
55 case __NR_times: 56 case __NR_times:
56 case __NR_uname: 57 case __NR_uname:
57 return ErrorCode(ErrorCode::ERR_ALLOWED); 58 return Allow();
58 case __NR_prlimit64: 59 case __NR_prlimit64:
59 return ErrorCode(EPERM); // See crbug.com/160157. 60 return Error(EPERM); // See crbug.com/160157.
60 default: 61 default:
61 // Default on the content baseline policy. 62 // Default on the content baseline policy.
62 return SandboxBPFBasePolicy::EvaluateSyscall(sandbox, sysno); 63 return SandboxBPFBasePolicy::EvaluateSyscall(sysno);
63 } 64 }
64 } 65 }
65 66
66 } // namespace content 67 } // namespace content
OLDNEW
« no previous file with comments | « content/common/sandbox_linux/bpf_renderer_policy_linux.h ('k') | content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698