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

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: fixing up comments 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 ~GpuBrokerProcessPolicy() override {} 127 ~GpuBrokerProcessPolicy() override {}
128 128
129 ResultExpr EvaluateSyscall(int system_call_number) const override; 129 ResultExpr EvaluateSyscall(int system_call_number) const override;
130 130
131 private: 131 private:
132 GpuBrokerProcessPolicy() {} 132 GpuBrokerProcessPolicy() {}
133 DISALLOW_COPY_AND_ASSIGN(GpuBrokerProcessPolicy); 133 DISALLOW_COPY_AND_ASSIGN(GpuBrokerProcessPolicy);
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 access, open,
138 // openat allowed. 138 // openat and in the non-Chrome OS case unlink 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 // The broker process needs to able to unlink the temporary
146 // files that it may create. This is used by DRI3.
147 case __NR_unlink:
148 #endif
144 return Allow(); 149 return Allow();
145 default: 150 default:
146 return GpuProcessPolicy::EvaluateSyscall(sysno); 151 return GpuProcessPolicy::EvaluateSyscall(sysno);
147 } 152 }
148 } 153 }
149 154
150 void UpdateProcessTypeToGpuBroker() { 155 void UpdateProcessTypeToGpuBroker() {
151 base::CommandLine::StringVector exec = 156 base::CommandLine::StringVector exec =
152 base::CommandLine::ForCurrentProcess()->GetArgs(); 157 base::CommandLine::ForCurrentProcess()->GetArgs();
153 base::CommandLine::Reset(); 158 base::CommandLine::Reset();
(...skipping 23 matching lines...) Expand all
177 182
178 GpuProcessPolicy::GpuProcessPolicy(bool allow_mincore) 183 GpuProcessPolicy::GpuProcessPolicy(bool allow_mincore)
179 : broker_process_(NULL), allow_mincore_(allow_mincore) { 184 : broker_process_(NULL), allow_mincore_(allow_mincore) {
180 } 185 }
181 186
182 GpuProcessPolicy::~GpuProcessPolicy() {} 187 GpuProcessPolicy::~GpuProcessPolicy() {}
183 188
184 // Main policy for x86_64/i386. Extended by CrosArmGpuProcessPolicy. 189 // Main policy for x86_64/i386. Extended by CrosArmGpuProcessPolicy.
185 ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const { 190 ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const {
186 switch (sysno) { 191 switch (sysno) {
192 #if !defined(OS_CHROMEOS)
193 case __NR_ftruncate:
194 #endif
187 case __NR_ioctl: 195 case __NR_ioctl:
188 return Allow(); 196 return Allow();
189 case __NR_mincore: 197 case __NR_mincore:
190 if (allow_mincore_) { 198 if (allow_mincore_) {
191 return Allow(); 199 return Allow();
192 } else { 200 } else {
193 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); 201 return SandboxBPFBasePolicy::EvaluateSyscall(sysno);
194 } 202 }
195 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) 203 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
196 // The Nvidia driver uses flags not in the baseline policy 204 // The Nvidia driver uses flags not in the baseline policy
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 262 }
255 263
256 return true; 264 return true;
257 } 265 }
258 266
259 void GpuProcessPolicy::InitGpuBrokerProcess( 267 void GpuProcessPolicy::InitGpuBrokerProcess(
260 sandbox::bpf_dsl::Policy* (*broker_sandboxer_allocator)(void), 268 sandbox::bpf_dsl::Policy* (*broker_sandboxer_allocator)(void),
261 const std::vector<BrokerFilePermission>& permissions_extra) { 269 const std::vector<BrokerFilePermission>& permissions_extra) {
262 static const char kDriRcPath[] = "/etc/drirc"; 270 static const char kDriRcPath[] = "/etc/drirc";
263 static const char kDriCard0Path[] = "/dev/dri/card0"; 271 static const char kDriCard0Path[] = "/dev/dri/card0";
272 static const char kDevShm[] = "/dev/shm/";
264 273
265 CHECK(broker_process_ == NULL); 274 CHECK(broker_process_ == NULL);
266 275
267 // All GPU process policies need these files brokered out. 276 // All GPU process policies need these files brokered out.
268 std::vector<BrokerFilePermission> permissions; 277 std::vector<BrokerFilePermission> permissions;
269 permissions.push_back(BrokerFilePermission::ReadWrite(kDriCard0Path)); 278 permissions.push_back(BrokerFilePermission::ReadWrite(kDriCard0Path));
270 permissions.push_back(BrokerFilePermission::ReadOnly(kDriRcPath)); 279 permissions.push_back(BrokerFilePermission::ReadOnly(kDriRcPath));
280 if (!IsChromeOS()) {
281 permissions.push_back(
282 BrokerFilePermission::ReadWriteCreateUnlinkRecursive(kDevShm));
283 }
271 284
272 // Add eventual extra files from permissions_extra. 285 // Add eventual extra files from permissions_extra.
273 for (const auto& perm : permissions_extra) { 286 for (const auto& perm : permissions_extra) {
274 permissions.push_back(perm); 287 permissions.push_back(perm);
275 } 288 }
276 289
277 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), permissions); 290 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), permissions);
278 // The initialization callback will perform generic initialization and then 291 // The initialization callback will perform generic initialization and then
279 // call broker_sandboxer_callback. 292 // call broker_sandboxer_callback.
280 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox, 293 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox,
281 broker_sandboxer_allocator))); 294 broker_sandboxer_allocator)));
282 } 295 }
283 296
284 } // namespace content 297 } // 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