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

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

Issue 10786023: Remove the seccomp filter disable. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased and removed unused includes. Created 8 years, 5 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 | 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 "content/public/common/sandbox_init.h" 5 #include "content/public/common/sandbox_init.h"
6 6
7 #if defined(__i386__) || defined(__x86_64__) 7 #if defined(__i386__) || defined(__x86_64__)
8 8
9 // This is an assert for GYP 9 // This is an assert for GYP
10 #if !defined(OS_LINUX) 10 #if !defined(OS_LINUX)
11 #error "Linux specific file compiled on non Linux OS!" 11 #error "Linux specific file compiled on non Linux OS!"
12 #endif 12 #endif
13 13
14 #include <asm/unistd.h> 14 #include <asm/unistd.h>
15 #include <errno.h> 15 #include <errno.h>
16 #include <fcntl.h> 16 #include <fcntl.h>
17 #include <linux/audit.h> 17 #include <linux/audit.h>
18 #include <linux/filter.h> 18 #include <linux/filter.h>
19 #include <signal.h> 19 #include <signal.h>
20 #include <string.h> 20 #include <string.h>
21 #include <sys/prctl.h> 21 #include <sys/prctl.h>
22 #include <sys/stat.h> 22 #include <sys/stat.h>
23 #include <sys/types.h> 23 #include <sys/types.h>
24 #include <ucontext.h> 24 #include <ucontext.h>
25 #include <unistd.h> 25 #include <unistd.h>
26 26
27 #include <vector> 27 #include <vector>
28 28
29 #include "base/command_line.h" 29 #include "base/command_line.h"
30 #include "base/environment.h"
31 #include "base/file_util.h" 30 #include "base/file_util.h"
32 #include "base/logging.h" 31 #include "base/logging.h"
33 #include "base/memory/scoped_ptr.h"
34 #include "base/time.h" 32 #include "base/time.h"
35 #include "content/public/common/content_switches.h" 33 #include "content/public/common/content_switches.h"
36 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 34 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
37 35
38 // These are fairly new and not defined in all headers yet. 36 // These are fairly new and not defined in all headers yet.
39 #if defined(__x86_64__) 37 #if defined(__x86_64__)
40 38
41 #ifndef __NR_process_vm_readv 39 #ifndef __NR_process_vm_readv
42 #define __NR_process_vm_readv 310 40 #define __NR_process_vm_readv 310
43 #endif 41 #endif
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 396 }
399 397
400 // Is the sandbox fully disabled for this process? 398 // Is the sandbox fully disabled for this process?
401 bool ShouldDisableSandbox(const CommandLine& command_line, 399 bool ShouldDisableSandbox(const CommandLine& command_line,
402 const std::string& process_type) { 400 const std::string& process_type) {
403 if (command_line.HasSwitch(switches::kNoSandbox) || 401 if (command_line.HasSwitch(switches::kNoSandbox) ||
404 command_line.HasSwitch(switches::kDisableSeccompFilterSandbox)) { 402 command_line.HasSwitch(switches::kDisableSeccompFilterSandbox)) {
405 return true; 403 return true;
406 } 404 }
407 405
408 if (!IsChromeOS()) {
409 // On non ChromeOS we never enable the sandbox AT ALL unless
410 // CHROME_ENABLE_SECCOMP is in the environment.
411 // TODO(jorgelo): remove this when seccomp BPF is included
412 // in an upstream release Linux kernel.
413 static const char kEnableSeccomp[] = "CHROME_ENABLE_SECCOMP";
414 scoped_ptr<base::Environment> env(base::Environment::Create());
415
416 if (!env->HasVar(kEnableSeccomp))
417 return true;
418 }
419
420 if (process_type == switches::kGpuProcess) { 406 if (process_type == switches::kGpuProcess) {
421 // The GPU sandbox is disabled by default in ChromeOS, enabled by default on 407 // The GPU sandbox is disabled by default in ChromeOS, enabled by default on
422 // generic Linux. 408 // generic Linux.
423 // TODO(jorgelo): when we feel comfortable, make this a policy decision 409 // TODO(jorgelo): when we feel comfortable, make this a policy decision
424 // instead. (i.e. move this to GetProcessSyscallPolicy) and return an 410 // instead. (i.e. move this to GetProcessSyscallPolicy) and return an
425 // AllowAllPolicy for lack of "--enable-gpu-sandbox". 411 // AllowAllPolicy for lack of "--enable-gpu-sandbox".
426 bool should_disable; 412 bool should_disable;
427 if (IsChromeOS()) { 413 if (IsChromeOS()) {
428 should_disable = true; 414 should_disable = true;
429 } else { 415 } else {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 526
541 namespace content { 527 namespace content {
542 528
543 void InitializeSandbox() { 529 void InitializeSandbox() {
544 #if defined(__i386__) || defined(__x86_64__) 530 #if defined(__i386__) || defined(__x86_64__)
545 InitializeSandbox_x86(); 531 InitializeSandbox_x86();
546 #endif 532 #endif
547 } 533 }
548 534
549 } // namespace content 535 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698