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

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

Issue 656023003: Fix crash with --use-gl=egl on Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 (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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 bool UpdateProcessTypeAndEnableSandbox(sandbox::bpf_dsl::SandboxBPFDSLPolicy* ( 162 bool UpdateProcessTypeAndEnableSandbox(sandbox::bpf_dsl::SandboxBPFDSLPolicy* (
163 *broker_sandboxer_allocator)(void)) { 163 *broker_sandboxer_allocator)(void)) {
164 DCHECK(broker_sandboxer_allocator); 164 DCHECK(broker_sandboxer_allocator);
165 UpdateProcessTypeToGpuBroker(); 165 UpdateProcessTypeToGpuBroker();
166 return SandboxSeccompBPF::StartSandboxWithExternalPolicy( 166 return SandboxSeccompBPF::StartSandboxWithExternalPolicy(
167 make_scoped_ptr(broker_sandboxer_allocator())); 167 make_scoped_ptr(broker_sandboxer_allocator()));
168 } 168 }
169 169
170 } // namespace 170 } // namespace
171 171
172 GpuProcessPolicy::GpuProcessPolicy() : broker_process_(NULL) {} 172 GpuProcessPolicy::GpuProcessPolicy() : GpuProcessPolicy(false) {
173 }
174
175 GpuProcessPolicy::GpuProcessPolicy(bool allow_mincore)
176 : broker_process_(NULL), allow_mincore_(allow_mincore) {
177 }
173 178
174 GpuProcessPolicy::~GpuProcessPolicy() {} 179 GpuProcessPolicy::~GpuProcessPolicy() {}
175 180
176 // Main policy for x86_64/i386. Extended by CrosArmGpuProcessPolicy. 181 // Main policy for x86_64/i386. Extended by CrosArmGpuProcessPolicy.
177 ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const { 182 ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const {
178 switch (sysno) { 183 switch (sysno) {
179 case __NR_ioctl: 184 case __NR_ioctl:
180 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) 185 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
181 // The Nvidia driver uses flags not in the baseline policy 186 // The Nvidia driver uses flags not in the baseline policy
182 // (MAP_LOCKED | MAP_EXECUTABLE | MAP_32BIT) 187 // (MAP_LOCKED | MAP_EXECUTABLE | MAP_32BIT)
183 case __NR_mmap: 188 case __NR_mmap:
184 #endif 189 #endif
185 // We also hit this on the linux_chromeos bot but don't yet know what 190 // We also hit this on the linux_chromeos bot but don't yet know what
186 // weird flags were involved. 191 // weird flags were involved.
187 case __NR_mprotect: 192 case __NR_mprotect:
188 // TODO(jln): restrict prctl. 193 // TODO(jln): restrict prctl.
189 case __NR_prctl: 194 case __NR_prctl:
190 return Allow(); 195 return Allow();
191 case __NR_access: 196 case __NR_access:
192 case __NR_open: 197 case __NR_open:
193 case __NR_openat: 198 case __NR_openat:
194 DCHECK(broker_process_); 199 DCHECK(broker_process_);
195 return Trap(GpuSIGSYS_Handler, broker_process_); 200 return Trap(GpuSIGSYS_Handler, broker_process_);
196 case __NR_setpriority: 201 case __NR_setpriority:
197 return sandbox::RestrictGetSetpriority(GetPolicyPid()); 202 return sandbox::RestrictGetSetpriority(GetPolicyPid());
198 case __NR_sched_getaffinity: 203 case __NR_sched_getaffinity:
199 case __NR_sched_setaffinity: 204 case __NR_sched_setaffinity:
200 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno); 205 return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno);
206 case __NR_mincore:
207 if (allow_mincore_)
208 return Allow();
Jorge Lucangeli Obes 2014/10/20 19:01:07 We try to keep this in alphabetical order, but it'
201 default: 209 default:
202 if (SyscallSets::IsEventFd(sysno)) 210 if (SyscallSets::IsEventFd(sysno))
203 return Allow(); 211 return Allow();
204 212
205 // Default on the baseline policy. 213 // Default on the baseline policy.
206 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); 214 return SandboxBPFBasePolicy::EvaluateSyscall(sysno);
207 } 215 }
208 } 216 }
209 217
210 bool GpuProcessPolicy::PreSandboxHook() { 218 bool GpuProcessPolicy::PreSandboxHook() {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), 278 broker_process_ = new BrokerProcess(GetFSDeniedErrno(),
271 read_whitelist, 279 read_whitelist,
272 write_whitelist); 280 write_whitelist);
273 // The initialization callback will perform generic initialization and then 281 // The initialization callback will perform generic initialization and then
274 // call broker_sandboxer_callback. 282 // call broker_sandboxer_callback.
275 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox, 283 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox,
276 broker_sandboxer_allocator))); 284 broker_sandboxer_allocator)));
277 } 285 }
278 286
279 } // namespace content 287 } // namespace content
OLDNEW
« no previous file with comments | « content/common/sandbox_linux/bpf_gpu_policy_linux.h ('k') | content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698