OLD | NEW |
---|---|
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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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? | 427 // Is the sandbox fully disabled for this process? |
428 bool ShouldDisableBpfSandbox(const CommandLine& command_line, | 428 bool ShouldDisableBpfSandbox(const CommandLine& command_line, |
429 const std::string& process_type) { | 429 const std::string& process_type) { |
430 if (process_type == switches::kGpuProcess) { | 430 if (process_type == switches::kGpuProcess) |
431 // The GPU sandbox is disabled by default in ChromeOS, enabled by default on | 431 return command_line.HasSwitch(switches::kDisableGpuSandbox); |
jln (very slow on Chromium)
2012/08/06 21:36:50
Also, could you kill this function and inline this
| |
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 | 432 |
450 return false; | 433 return false; |
451 } | 434 } |
452 | 435 |
453 playground2::Sandbox::EvaluateSyscall GetProcessSyscallPolicy( | 436 playground2::Sandbox::EvaluateSyscall GetProcessSyscallPolicy( |
454 const CommandLine& command_line, | 437 const CommandLine& command_line, |
455 const std::string& process_type) { | 438 const std::string& process_type) { |
456 #if defined(__x86_64__) | 439 #if defined(__x86_64__) |
457 if (process_type == switches::kGpuProcess) { | 440 if (process_type == switches::kGpuProcess) { |
458 return GpuProcessPolicy_x86_64; | 441 if (command_line.HasSwitch(switches::kEnableGpuSandbox)) |
442 return GpuProcessPolicy_x86_64; | |
443 else | |
444 return AllowAllPolicy; | |
459 } | 445 } |
460 | 446 |
461 if (process_type == switches::kPpapiPluginProcess) { | 447 if (process_type == switches::kPpapiPluginProcess) { |
462 // TODO(jln): figure out what to do with non-Flash PPAPI | 448 // TODO(jln): figure out what to do with non-Flash PPAPI |
463 // out-of-process plug-ins. | 449 // out-of-process plug-ins. |
464 return FlashProcessPolicy_x86_64; | 450 return FlashProcessPolicy_x86_64; |
465 } | 451 } |
466 | 452 |
467 if (process_type == switches::kRendererProcess || | 453 if (process_type == switches::kRendererProcess || |
468 process_type == switches::kWorkerProcess) { | 454 process_type == switches::kWorkerProcess) { |
469 return BlacklistPtracePolicy; | 455 return BlacklistPtracePolicy; |
470 } | 456 } |
471 NOTREACHED(); | 457 NOTREACHED(); |
472 // This will be our default if we need one. | 458 // This will be our default if we need one. |
473 return AllowAllPolicy; | 459 return AllowAllPolicy; |
474 #else | 460 #else |
461 if (process_type == switches::kGpuProcess) { | |
462 if (command_line.HasSwitch(switches::kEnableGpuSandbox)) | |
463 return BlacklistPtracePolicy; | |
464 else | |
465 return AllowAllPolicy; | |
466 } | |
467 | |
475 // On IA32, we only have a small blacklist at the moment. | 468 // On IA32, we only have a small blacklist at the moment. |
476 (void) process_type; | |
477 return BlacklistPtracePolicy; | 469 return BlacklistPtracePolicy; |
478 #endif // __x86_64__ | 470 #endif // __x86_64__ |
479 } | 471 } |
480 | 472 |
481 // Initialize the seccomp-bpf sandbox. | 473 // Initialize the seccomp-bpf sandbox. |
482 bool StartBpfSandbox_x86(const CommandLine& command_line, | 474 bool StartBpfSandbox_x86(const CommandLine& command_line, |
483 const std::string& process_type) { | 475 const std::string& process_type) { |
484 playground2::Sandbox::EvaluateSyscall SyscallPolicy = | 476 playground2::Sandbox::EvaluateSyscall SyscallPolicy = |
485 GetProcessSyscallPolicy(command_line, process_type); | 477 GetProcessSyscallPolicy(command_line, process_type); |
486 | 478 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 // Process-specific policy. | 531 // Process-specific policy. |
540 ShouldEnableSeccompBpf(process_type) && | 532 ShouldEnableSeccompBpf(process_type) && |
541 SupportsSandbox()) { | 533 SupportsSandbox()) { |
542 return StartBpfSandbox_x86(command_line, process_type); | 534 return StartBpfSandbox_x86(command_line, process_type); |
543 } | 535 } |
544 #endif | 536 #endif |
545 return false; | 537 return false; |
546 } | 538 } |
547 | 539 |
548 } // namespace content | 540 } // namespace content |
OLD | NEW |