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

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: define use_vgem_map in single place Created 5 years, 3 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 {
32
33 ResultExpr RestrictIoctl() {
34 #if defined(USE_VGEM_MAP)
35 // The type of DRM_IOCTL_XXX macro is long unsigned int.
mdempsky 2015/09/02 22:19:38 For simplicity, I would suggest writing this as ju
dshwang 2015/09/03 08:38:04 Thx for taking your time. Done.
36 auto reference_type = DRM_IOCTL_GEM_CLOSE;
37 #else
38 auto reference_type = TCGETS;
39 #endif
40 const Arg<decltype(reference_type)> request(1);
41 return Switch(request)
42 .SANDBOX_BPF_DSL_CASES(
43 (static_cast<decltype(reference_type)>(TCGETS), FIONREAD), Allow())
44 #if defined(USE_VGEM_MAP)
45 .SANDBOX_BPF_DSL_CASES((DRM_IOCTL_GEM_CLOSE, DRM_IOCTL_VGEM_MODE_MAP_DUMB,
46 DRM_IOCTL_PRIME_FD_TO_HANDLE),
47 Allow())
48 #endif
49 .Default(sandbox::CrashSIGSYSIoctl());
50 }
51
52 } // namespace
53
24 RendererProcessPolicy::RendererProcessPolicy() {} 54 RendererProcessPolicy::RendererProcessPolicy() {}
25 RendererProcessPolicy::~RendererProcessPolicy() {} 55 RendererProcessPolicy::~RendererProcessPolicy() {}
26 56
27 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { 57 ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const {
28 switch (sysno) { 58 switch (sysno) {
29 // The baseline policy allows __NR_clock_gettime. Allow 59 // The baseline policy allows __NR_clock_gettime. Allow
30 // clock_getres() for V8. crbug.com/329053. 60 // clock_getres() for V8. crbug.com/329053.
31 case __NR_clock_getres: 61 case __NR_clock_getres:
32 return sandbox::RestrictClockID(); 62 return sandbox::RestrictClockID();
33 case __NR_ioctl: 63 case __NR_ioctl:
34 return sandbox::RestrictIoctl(); 64 return RestrictIoctl();
35 // Allow the system calls below. 65 // Allow the system calls below.
36 case __NR_fdatasync: 66 case __NR_fdatasync:
37 case __NR_fsync: 67 case __NR_fsync:
38 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) 68 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
39 case __NR_getrlimit: 69 case __NR_getrlimit:
40 #endif 70 #endif
41 #if defined(__i386__) || defined(__arm__) 71 #if defined(__i386__) || defined(__arm__)
42 case __NR_ugetrlimit: 72 case __NR_ugetrlimit:
43 #endif 73 #endif
44 case __NR_mremap: // See crbug.com/149834. 74 case __NR_mremap: // See crbug.com/149834.
(...skipping 12 matching lines...) Expand all
57 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); 87 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno);
58 case __NR_prlimit64: 88 case __NR_prlimit64:
59 return Error(EPERM); // See crbug.com/160157. 89 return Error(EPERM); // See crbug.com/160157.
60 default: 90 default:
61 // Default on the content baseline policy. 91 // Default on the content baseline policy.
62 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); 92 return SandboxBPFBasePolicy::EvaluateSyscall(sysno);
63 } 93 }
64 } 94 }
65 95
66 } // namespace content 96 } // namespace content
OLDNEW
« no previous file with comments | « content/common/BUILD.gn ('k') | content/content_common.gypi » ('j') | ui/ozone/ozone.gni » ('J')

Powered by Google App Engine
This is Rietveld 408576698