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

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: Add comment describing --enable-gpu-sandbox flag. 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 // On Chrome OS, --enable-gpu-sandbox enables the more restrictive policy.
433 if (IsChromeOS() && !command_line.HasSwitch(switches::kEnableGpuSandbox))
434 return BlacklistPtracePolicy;
435 else
436 return GpuProcessPolicy_x86_64;
459 } 437 }
460 438
461 if (process_type == switches::kPpapiPluginProcess) { 439 if (process_type == switches::kPpapiPluginProcess) {
462 // TODO(jln): figure out what to do with non-Flash PPAPI 440 // TODO(jln): figure out what to do with non-Flash PPAPI
463 // out-of-process plug-ins. 441 // out-of-process plug-ins.
464 return FlashProcessPolicy_x86_64; 442 return FlashProcessPolicy_x86_64;
465 } 443 }
466 444
467 if (process_type == switches::kRendererProcess || 445 if (process_type == switches::kRendererProcess ||
468 process_type == switches::kWorkerProcess) { 446 process_type == switches::kWorkerProcess) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 return true; 485 return true;
508 } else { 486 } else {
509 return false; 487 return false;
510 } 488 }
511 } 489 }
512 490
513 bool SandboxSeccompBpf::ShouldEnableSeccompBpf( 491 bool SandboxSeccompBpf::ShouldEnableSeccompBpf(
514 const std::string& process_type) { 492 const std::string& process_type) {
515 #if defined(SECCOMP_BPF_SANDBOX) 493 #if defined(SECCOMP_BPF_SANDBOX)
516 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 494 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
517 return !ShouldDisableBpfSandbox(command_line, process_type); 495 if (process_type == switches::kGpuProcess)
496 return !command_line.HasSwitch(switches::kDisableGpuSandbox);
497
498 return true;
518 #endif 499 #endif
519 return false; 500 return false;
520 } 501 }
521 502
522 bool SandboxSeccompBpf::SupportsSandbox() { 503 bool SandboxSeccompBpf::SupportsSandbox() {
523 #if defined(SECCOMP_BPF_SANDBOX) 504 #if defined(SECCOMP_BPF_SANDBOX)
524 // TODO(jln): pass the saved proc_fd_ from the LinuxSandbox singleton 505 // TODO(jln): pass the saved proc_fd_ from the LinuxSandbox singleton
525 // here. 506 // here.
526 if (playground2::Sandbox::supportsSeccompSandbox(-1) == 507 if (playground2::Sandbox::supportsSeccompSandbox(-1) ==
527 playground2::Sandbox::STATUS_AVAILABLE) { 508 playground2::Sandbox::STATUS_AVAILABLE) {
(...skipping 11 matching lines...) Expand all
539 // Process-specific policy. 520 // Process-specific policy.
540 ShouldEnableSeccompBpf(process_type) && 521 ShouldEnableSeccompBpf(process_type) &&
541 SupportsSandbox()) { 522 SupportsSandbox()) {
542 return StartBpfSandbox_x86(command_line, process_type); 523 return StartBpfSandbox_x86(command_line, process_type);
543 } 524 }
544 #endif 525 #endif
545 return false; 526 return false;
546 } 527 }
547 528
548 } // namespace content 529 } // 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