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

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

Issue 759613008: bpf gpu policy: Change GPU bpf policy to support DRI3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | content/gpu/gpu_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_gpu_policy_linux.h" 5 #include "content/common/sandbox_linux/bpf_gpu_policy_linux.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 }; 134 };
135 135
136 // x86_64/i386 or desktop ARM. 136 // x86_64/i386 or desktop ARM.
137 // A GPU broker policy is the same as a GPU policy with open and 137 // A GPU broker policy is the same as a GPU policy with open and
138 // openat allowed. 138 // openat allowed.
139 ResultExpr GpuBrokerProcessPolicy::EvaluateSyscall(int sysno) const { 139 ResultExpr GpuBrokerProcessPolicy::EvaluateSyscall(int sysno) const {
140 switch (sysno) { 140 switch (sysno) {
141 case __NR_access: 141 case __NR_access:
142 case __NR_open: 142 case __NR_open:
143 case __NR_openat: 143 case __NR_openat:
144 #if !defined(OS_CHROMEOS)
145 case __NR_unlink:
146 #endif
144 return Allow(); 147 return Allow();
145 default: 148 default:
146 return GpuProcessPolicy::EvaluateSyscall(sysno); 149 return GpuProcessPolicy::EvaluateSyscall(sysno);
147 } 150 }
148 } 151 }
149 152
150 void UpdateProcessTypeToGpuBroker() { 153 void UpdateProcessTypeToGpuBroker() {
151 base::CommandLine::StringVector exec = 154 base::CommandLine::StringVector exec =
152 base::CommandLine::ForCurrentProcess()->GetArgs(); 155 base::CommandLine::ForCurrentProcess()->GetArgs();
153 base::CommandLine::Reset(); 156 base::CommandLine::Reset();
(...skipping 23 matching lines...) Expand all
177 180
178 GpuProcessPolicy::GpuProcessPolicy(bool allow_mincore) 181 GpuProcessPolicy::GpuProcessPolicy(bool allow_mincore)
179 : broker_process_(NULL), allow_mincore_(allow_mincore) { 182 : broker_process_(NULL), allow_mincore_(allow_mincore) {
180 } 183 }
181 184
182 GpuProcessPolicy::~GpuProcessPolicy() {} 185 GpuProcessPolicy::~GpuProcessPolicy() {}
183 186
184 // Main policy for x86_64/i386. Extended by CrosArmGpuProcessPolicy. 187 // Main policy for x86_64/i386. Extended by CrosArmGpuProcessPolicy.
185 ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const { 188 ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const {
186 switch (sysno) { 189 switch (sysno) {
190 #if !defined(OS_CHROMEOS)
191 case __NR_ftruncate:
192 #endif
187 case __NR_ioctl: 193 case __NR_ioctl:
188 return Allow(); 194 return Allow();
189 case __NR_mincore: 195 case __NR_mincore:
190 if (allow_mincore_) { 196 if (allow_mincore_) {
191 return Allow(); 197 return Allow();
192 } else { 198 } else {
193 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); 199 return SandboxBPFBasePolicy::EvaluateSyscall(sysno);
194 } 200 }
195 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) 201 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
196 // The Nvidia driver uses flags not in the baseline policy 202 // The Nvidia driver uses flags not in the baseline policy
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 260 }
255 261
256 return true; 262 return true;
257 } 263 }
258 264
259 void GpuProcessPolicy::InitGpuBrokerProcess( 265 void GpuProcessPolicy::InitGpuBrokerProcess(
260 sandbox::bpf_dsl::Policy* (*broker_sandboxer_allocator)(void), 266 sandbox::bpf_dsl::Policy* (*broker_sandboxer_allocator)(void),
261 const std::vector<BrokerFilePermission>& permissions_extra) { 267 const std::vector<BrokerFilePermission>& permissions_extra) {
262 static const char kDriRcPath[] = "/etc/drirc"; 268 static const char kDriRcPath[] = "/etc/drirc";
263 static const char kDriCard0Path[] = "/dev/dri/card0"; 269 static const char kDriCard0Path[] = "/dev/dri/card0";
270 static const char kDevShm[] = "/dev/shm/";
264 271
265 CHECK(broker_process_ == NULL); 272 CHECK(broker_process_ == NULL);
266 273
267 // All GPU process policies need these files brokered out. 274 // All GPU process policies need these files brokered out.
268 std::vector<BrokerFilePermission> permissions; 275 std::vector<BrokerFilePermission> permissions;
269 permissions.push_back(BrokerFilePermission::ReadWrite(kDriCard0Path)); 276 permissions.push_back(BrokerFilePermission::ReadWrite(kDriCard0Path));
270 permissions.push_back(BrokerFilePermission::ReadOnly(kDriRcPath)); 277 permissions.push_back(BrokerFilePermission::ReadOnly(kDriRcPath));
271 278 if (!IsChromeOS()) {
279 permissions.push_back(
280 BrokerFilePermission::ReadWriteCreateUnlinkRecursive(kDevShm));
281 }
Jorge Lucangeli Obes 2014/12/02 21:09:06 Let's keep the empty line below.
leecam 2014/12/03 17:08:51 Done.
272 // Add eventual extra files from permissions_extra. 282 // Add eventual extra files from permissions_extra.
273 for (const auto& perm : permissions_extra) { 283 for (const auto& perm : permissions_extra) {
274 permissions.push_back(perm); 284 permissions.push_back(perm);
275 } 285 }
276 286
277 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), permissions); 287 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), permissions);
278 // The initialization callback will perform generic initialization and then 288 // The initialization callback will perform generic initialization and then
279 // call broker_sandboxer_callback. 289 // call broker_sandboxer_callback.
280 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox, 290 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox,
281 broker_sandboxer_allocator))); 291 broker_sandboxer_allocator)));
282 } 292 }
283 293
284 } // namespace content 294 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/gpu/gpu_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698