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

Side by Side Diff: content/common/sandbox_seccomp_bpf_linux.cc

Issue 10836118: Clean up GPU process seccomp-bpf sandbox policies. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Final agreement with jln re: policies. Created 8 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
« no previous file with comments | « content/common/sandbox_init_linux.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <asm/unistd.h> 5 #include <asm/unistd.h>
6 #include <dlfcn.h> 6 #include <dlfcn.h>
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <linux/audit.h> 9 #include <linux/audit.h>
10 #include <linux/filter.h> 10 #include <linux/filter.h>
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 // TODO(jorgelo): generalize this to other platforms. 417 // TODO(jorgelo): generalize this to other platforms.
418 if (IsAcceleratedVideoDecodeEnabled()) { 418 if (IsAcceleratedVideoDecodeEnabled()) {
419 const char kI965DrvVideoPath_64[] = 419 const char kI965DrvVideoPath_64[] =
420 "/usr/lib64/va/drivers/i965_drv_video.so"; 420 "/usr/lib64/va/drivers/i965_drv_video.so";
421 dlopen(kI965DrvVideoPath_64, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); 421 dlopen(kI965DrvVideoPath_64, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
422 } 422 }
423 } 423 }
424 #endif 424 #endif
425 } 425 }
426 426
427 // Is the sandbox fully disabled for this process?
428 bool ShouldDisableBpfSandbox(const CommandLine& command_line,
429 const std::string& process_type) {
430 if (process_type == switches::kGpuProcess) {
431 // The GPU sandbox is disabled by default in ChromeOS, enabled by default on
432 // generic Linux.
433 // TODO(jorgelo): when we feel comfortable, make this a policy decision
434 // instead. (i.e. move this to GetProcessSyscallPolicy) and return an
435 // AllowAllPolicy for lack of "--enable-gpu-sandbox".
436 bool should_disable;
437 if (IsChromeOS()) {
438 should_disable = true;
439 } else {
440 should_disable = false;
441 }
442
443 if (command_line.HasSwitch(switches::kEnableGpuSandbox))
444 should_disable = false;
445 if (command_line.HasSwitch(switches::kDisableGpuSandbox))
446 should_disable = true;
447 return should_disable;
448 }
449
450 return false;
451 }
452
453 playground2::Sandbox::EvaluateSyscall GetProcessSyscallPolicy( 427 playground2::Sandbox::EvaluateSyscall GetProcessSyscallPolicy(
454 const CommandLine& command_line, 428 const CommandLine& command_line,
455 const std::string& process_type) { 429 const std::string& process_type) {
456 #if defined(__x86_64__) 430 #if defined(__x86_64__)
457 if (process_type == switches::kGpuProcess) { 431 if (process_type == switches::kGpuProcess) {
458 return GpuProcessPolicy_x86_64; 432 if (!IsChromeOS() || command_line.HasSwitch(switches::kEnableGpuSandbox))
jln (very slow on Chromium) 2012/08/06 22:15:24 Do you mind putting the "exceptional case" first?
433 return GpuProcessPolicy_x86_64;
434 else
435 return BlacklistPtracePolicy;
459 } 436 }
460 437
461 if (process_type == switches::kPpapiPluginProcess) { 438 if (process_type == switches::kPpapiPluginProcess) {
462 // TODO(jln): figure out what to do with non-Flash PPAPI 439 // TODO(jln): figure out what to do with non-Flash PPAPI
463 // out-of-process plug-ins. 440 // out-of-process plug-ins.
464 return FlashProcessPolicy_x86_64; 441 return FlashProcessPolicy_x86_64;
465 } 442 }
466 443
467 if (process_type == switches::kRendererProcess || 444 if (process_type == switches::kRendererProcess ||
468 process_type == switches::kWorkerProcess) { 445 process_type == switches::kWorkerProcess) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 return true; 484 return true;
508 } else { 485 } else {
509 return false; 486 return false;
510 } 487 }
511 } 488 }
512 489
513 bool SandboxSeccompBpf::ShouldEnableSeccompBpf( 490 bool SandboxSeccompBpf::ShouldEnableSeccompBpf(
514 const std::string& process_type) { 491 const std::string& process_type) {
515 #if defined(SECCOMP_BPF_SANDBOX) 492 #if defined(SECCOMP_BPF_SANDBOX)
516 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 493 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
517 return !ShouldDisableBpfSandbox(command_line, process_type); 494 if (process_type == switches::kGpuProcess)
495 return !command_line.HasSwitch(switches::kDisableGpuSandbox);
496
497 return true;
518 #endif 498 #endif
519 return false; 499 return false;
520 } 500 }
521 501
522 bool SandboxSeccompBpf::SupportsSandbox() { 502 bool SandboxSeccompBpf::SupportsSandbox() {
523 #if defined(SECCOMP_BPF_SANDBOX) 503 #if defined(SECCOMP_BPF_SANDBOX)
524 // TODO(jln): pass the saved proc_fd_ from the LinuxSandbox singleton 504 // TODO(jln): pass the saved proc_fd_ from the LinuxSandbox singleton
525 // here. 505 // here.
526 if (playground2::Sandbox::supportsSeccompSandbox(-1) == 506 if (playground2::Sandbox::supportsSeccompSandbox(-1) ==
527 playground2::Sandbox::STATUS_AVAILABLE) { 507 playground2::Sandbox::STATUS_AVAILABLE) {
(...skipping 11 matching lines...) Expand all
539 // Process-specific policy. 519 // Process-specific policy.
540 ShouldEnableSeccompBpf(process_type) && 520 ShouldEnableSeccompBpf(process_type) &&
541 SupportsSandbox()) { 521 SupportsSandbox()) {
542 return StartBpfSandbox_x86(command_line, process_type); 522 return StartBpfSandbox_x86(command_line, process_type);
543 } 523 }
544 #endif 524 #endif
545 return false; 525 return false;
546 } 526 }
547 527
548 } // namespace content 528 } // namespace content
OLDNEW
« no previous file with comments | « content/common/sandbox_init_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698