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

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

Issue 1253363004: ozone gbm: whitelist 3 DRM ioctl code for native GpuMemoryBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move code to content/ Created 5 years, 4 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
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 #include <sys/ioctl.h>
8 9
9 #include "base/basictypes.h" 10 #include "base/basictypes.h"
10 #include "build/build_config.h" 11 #include "build/build_config.h"
11 #include "content/common/sandbox_linux/sandbox_linux.h" 12 #include "content/common/sandbox_linux/sandbox_linux.h"
12 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" 13 #include "sandbox/linux/bpf_dsl/bpf_dsl.h"
14 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h"
13 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" 15 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h"
14 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" 16 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h"
15 #include "sandbox/linux/system_headers/linux_syscalls.h" 17 #include "sandbox/linux/system_headers/linux_syscalls.h"
16 18
19 #if defined(USE_VGEM_MAP)
20 #include <libdrm/vgem_drm.h>
21 #endif
22
17 using sandbox::SyscallSets; 23 using sandbox::SyscallSets;
18 using sandbox::bpf_dsl::Allow; 24 using sandbox::bpf_dsl::Allow;
25 using sandbox::bpf_dsl::Arg;
19 using sandbox::bpf_dsl::Error; 26 using sandbox::bpf_dsl::Error;
20 using sandbox::bpf_dsl::ResultExpr; 27 using sandbox::bpf_dsl::ResultExpr;
21 28
22 namespace content { 29 namespace content {
23 30
31 namespace {
brettw 2015/08/26 22:27:49 Blank line after here.
dshwang 2015/08/27 12:47:09 Done.
32 ResultExpr RestrictIoctl() {
33 #if defined(USE_VGEM_MAP)
34 // The type of DRM_IOCTL_XXX macro is long unsigned int.
35 auto reference_type = DRM_IOCTL_GEM_CLOSE;
36 #else
37 auto reference_type = TCGETS;
38 #endif
39 const Arg<decltype(reference_type)> request(1);
40 return Switch(request)
41 .SANDBOX_BPF_DSL_CASES(
42 (static_cast<decltype(reference_type)>(TCGETS), FIONREAD), Allow())
43 #if defined(USE_VGEM_MAP)
44 .SANDBOX_BPF_DSL_CASES((DRM_IOCTL_GEM_CLOSE, DRM_IOCTL_VGEM_MODE_MAP_DUMB,
45 DRM_IOCTL_PRIME_FD_TO_HANDLE),
46 Allow())
47 #endif
48 .Default(sandbox::CrashSIGSYSIoctl());
49 }
50 }
brettw 2015/08/26 22:27:49 Blank line before here, and this line should look
dshwang 2015/08/27 12:47:09 Done.
51
24 RendererProcessPolicy::RendererProcessPolicy() {} 52 RendererProcessPolicy::RendererProcessPolicy() {}
25 RendererProcessPolicy::~RendererProcessPolicy() {} 53 RendererProcessPolicy::~RendererProcessPolicy() {}
26 54
27 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { 55 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const {
28 switch (sysno) { 56 switch (sysno) {
29 // The baseline policy allows __NR_clock_gettime. Allow 57 // The baseline policy allows __NR_clock_gettime. Allow
30 // clock_getres() for V8. crbug.com/329053. 58 // clock_getres() for V8. crbug.com/329053.
31 case __NR_clock_getres: 59 case __NR_clock_getres:
32 return sandbox::RestrictClockID(); 60 return sandbox::RestrictClockID();
33 case __NR_ioctl: 61 case __NR_ioctl:
34 return sandbox::RestrictIoctl(); 62 return RestrictIoctl();
35 // Allow the system calls below. 63 // Allow the system calls below.
36 case __NR_fdatasync: 64 case __NR_fdatasync:
37 case __NR_fsync: 65 case __NR_fsync:
38 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) 66 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
39 case __NR_getrlimit: 67 case __NR_getrlimit:
40 #endif 68 #endif
41 #if defined(__i386__) || defined(__arm__) 69 #if defined(__i386__) || defined(__arm__)
42 case __NR_ugetrlimit: 70 case __NR_ugetrlimit:
43 #endif 71 #endif
44 case __NR_mremap: // See crbug.com/149834. 72 case __NR_mremap: // See crbug.com/149834.
(...skipping 12 matching lines...) Expand all
57 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); 85 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno);
58 case __NR_prlimit64: 86 case __NR_prlimit64:
59 return Error(EPERM); // See crbug.com/160157. 87 return Error(EPERM); // See crbug.com/160157.
60 default: 88 default:
61 // Default on the content baseline policy. 89 // Default on the content baseline policy.
62 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); 90 return SandboxBPFBasePolicy::EvaluateSyscall(sysno);
63 } 91 }
64 } 92 }
65 93
66 } // namespace content 94 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698