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

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

Issue 10534049: Disable the seccomp filter GPU process sandbox by default on Chrome OS. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Correct alignment of '=' sign for cmdline flag. Created 8 years, 6 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 | « 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) 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 "content/public/common/sandbox_init.h" 5 #include "content/public/common/sandbox_init.h"
6 6
7 #if defined(OS_LINUX) && defined(__x86_64__) 7 #if defined(OS_LINUX) && defined(__x86_64__)
8 8
9 #include <asm/unistd.h> 9 #include <asm/unistd.h>
10 #include <errno.h> 10 #include <errno.h>
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 PLOG_IF(FATAL, ret != 0) << "prctl(PR_SET_NO_NEW_PRIVS) failed"; 381 PLOG_IF(FATAL, ret != 0) << "prctl(PR_SET_NO_NEW_PRIVS) failed";
382 382
383 struct sock_fprog fprog; 383 struct sock_fprog fprog;
384 fprog.len = program.size(); 384 fprog.len = program.size();
385 fprog.filter = const_cast<struct sock_filter*>(&program[0]); 385 fprog.filter = const_cast<struct sock_filter*>(&program[0]);
386 386
387 ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &fprog, 0, 0); 387 ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &fprog, 0, 0);
388 PLOG_IF(FATAL, ret != 0) << "Failed to install filter."; 388 PLOG_IF(FATAL, ret != 0) << "Failed to install filter.";
389 } 389 }
390 390
391 static bool ShouldEnableGPUSandbox() {
392 // Default setting is: enabled for Linux, disabled for Chrome OS.
393 // '--disable-gpu-sandbox' takes precedence over '--enable-gpu-sandbox'.
394 #if defined(OS_CHROMEOS)
395 bool res = false;
396 #else
397 bool res = true;
398 #endif
399
400 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
401
402 if (command_line.HasSwitch(switches::kEnableGpuSandbox)) {
403 res = true;
404 }
405 if (command_line.HasSwitch(switches::kDisableGpuSandbox)) {
406 res = false;
407 }
408
409 return res;
410 }
411
391 } // anonymous namespace 412 } // anonymous namespace
392 413
393 namespace content { 414 namespace content {
394 415
395 void InitializeSandbox() { 416 void InitializeSandbox() {
396 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 417 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
397 if (command_line.HasSwitch(switches::kNoSandbox) || 418 if (command_line.HasSwitch(switches::kNoSandbox) ||
398 command_line.HasSwitch(switches::kDisableSeccompFilterSandbox)) 419 command_line.HasSwitch(switches::kDisableSeccompFilterSandbox))
399 return; 420 return;
400 421
401 std::string process_type = 422 std::string process_type =
402 command_line.GetSwitchValueASCII(switches::kProcessType); 423 command_line.GetSwitchValueASCII(switches::kProcessType);
403 if (process_type == switches::kGpuProcess && 424 if (process_type == switches::kGpuProcess &&
404 command_line.HasSwitch(switches::kDisableGpuSandbox)) 425 !ShouldEnableGPUSandbox())
405 return; 426 return;
406 427
407 if (!CanUseSeccompFilters()) 428 if (!CanUseSeccompFilters())
408 return; 429 return;
409 430
410 CheckSingleThreaded(); 431 CheckSingleThreaded();
411 432
412 std::vector<struct sock_filter> program; 433 std::vector<struct sock_filter> program;
413 EmitPreamble(&program); 434 EmitPreamble(&program);
414 435
(...skipping 20 matching lines...) Expand all
435 #else 456 #else
436 457
437 namespace content { 458 namespace content {
438 459
439 void InitializeSandbox() { 460 void InitializeSandbox() {
440 } 461 }
441 462
442 } // namespace content 463 } // namespace content
443 464
444 #endif 465 #endif
445
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