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

Side by Side Diff: components/nacl/loader/nacl_helper_linux.cc

Issue 239703011: Reland: Add seccomp sandbox for non-SFI NaCl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 | « components/nacl.gyp ('k') | components/nacl/loader/nonsfi/DEPS » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // A mini-zygote specifically for Native Client. 5 // A mini-zygote specifically for Native Client.
6 6
7 #include "components/nacl/loader/nacl_helper_linux.h" 7 #include "components/nacl/loader/nacl_helper_linux.h"
8 8
9 #include <errno.h> 9 #include <errno.h>
10 #include <fcntl.h> 10 #include <fcntl.h>
(...skipping 14 matching lines...) Expand all
25 #include "base/memory/scoped_ptr.h" 25 #include "base/memory/scoped_ptr.h"
26 #include "base/message_loop/message_loop.h" 26 #include "base/message_loop/message_loop.h"
27 #include "base/posix/eintr_wrapper.h" 27 #include "base/posix/eintr_wrapper.h"
28 #include "base/posix/global_descriptors.h" 28 #include "base/posix/global_descriptors.h"
29 #include "base/posix/unix_domain_socket_linux.h" 29 #include "base/posix/unix_domain_socket_linux.h"
30 #include "base/process/kill.h" 30 #include "base/process/kill.h"
31 #include "base/rand_util.h" 31 #include "base/rand_util.h"
32 #include "components/nacl/common/nacl_switches.h" 32 #include "components/nacl/common/nacl_switches.h"
33 #include "components/nacl/loader/nacl_listener.h" 33 #include "components/nacl/loader/nacl_listener.h"
34 #include "components/nacl/loader/nacl_sandbox_linux.h" 34 #include "components/nacl/loader/nacl_sandbox_linux.h"
35 #include "components/nacl/loader/nonsfi/nonsfi_sandbox.h"
35 #include "content/public/common/zygote_fork_delegate_linux.h" 36 #include "content/public/common/zygote_fork_delegate_linux.h"
36 #include "crypto/nss_util.h" 37 #include "crypto/nss_util.h"
37 #include "ipc/ipc_descriptors.h" 38 #include "ipc/ipc_descriptors.h"
38 #include "ipc/ipc_switches.h" 39 #include "ipc/ipc_switches.h"
39 #include "sandbox/linux/services/credentials.h" 40 #include "sandbox/linux/services/credentials.h"
40 #include "sandbox/linux/services/libc_urandom_override.h" 41 #include "sandbox/linux/services/libc_urandom_override.h"
41 #include "sandbox/linux/services/thread_helpers.h" 42 #include "sandbox/linux/services/thread_helpers.h"
42 #include "sandbox/linux/suid/client/setuid_sandbox_client.h" 43 #include "sandbox/linux/suid/client/setuid_sandbox_client.h"
43 44
44 namespace { 45 namespace {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 if (uses_nonsfi_mode) { 86 if (uses_nonsfi_mode) {
86 const bool can_be_no_sandbox = CommandLine::ForCurrentProcess()->HasSwitch( 87 const bool can_be_no_sandbox = CommandLine::ForCurrentProcess()->HasSwitch(
87 switches::kNaClDangerousNoSandboxNonSfi); 88 switches::kNaClDangerousNoSandboxNonSfi);
88 const bool setuid_sandbox_enabled = IsSandboxed(); 89 const bool setuid_sandbox_enabled = IsSandboxed();
89 if (!setuid_sandbox_enabled) { 90 if (!setuid_sandbox_enabled) {
90 if (can_be_no_sandbox) 91 if (can_be_no_sandbox)
91 LOG(ERROR) << "DANGEROUS: Running non-SFI NaCl without SUID sandbox!"; 92 LOG(ERROR) << "DANGEROUS: Running non-SFI NaCl without SUID sandbox!";
92 else 93 else
93 LOG(FATAL) << "SUID sandbox is mandatory for non-SFI NaCl"; 94 LOG(FATAL) << "SUID sandbox is mandatory for non-SFI NaCl";
94 } 95 }
95 const bool bpf_sandbox_initialized = InitializeBPFSandbox(); 96 const bool bpf_sandbox_initialized = nacl::nonsfi::InitializeBPFSandbox();
96 if (!bpf_sandbox_initialized) { 97 if (!bpf_sandbox_initialized) {
97 if (can_be_no_sandbox) { 98 if (can_be_no_sandbox) {
98 LOG(ERROR) 99 LOG(ERROR)
99 << "DANGEROUS: Running non-SFI NaCl without seccomp-bpf sandbox!"; 100 << "DANGEROUS: Running non-SFI NaCl without seccomp-bpf sandbox!";
100 } else { 101 } else {
101 LOG(FATAL) << "Could not initialize NaCl's second " 102 LOG(FATAL) << "Could not initialize NaCl's second "
102 << "layer sandbox (seccomp-bpf) for non-SFI mode."; 103 << "layer sandbox (seccomp-bpf) for non-SFI mode.";
103 } 104 }
104 } 105 }
105 } else { 106 } else {
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // Now handle requests from the Zygote. 455 // Now handle requests from the Zygote.
455 while (true) { 456 while (true) {
456 bool request_handled = HandleZygoteRequest(kNaClZygoteDescriptor, 457 bool request_handled = HandleZygoteRequest(kNaClZygoteDescriptor,
457 system_info); 458 system_info);
458 // Do not turn this into a CHECK() without thinking about robustness 459 // Do not turn this into a CHECK() without thinking about robustness
459 // against malicious IPC requests. 460 // against malicious IPC requests.
460 DCHECK(request_handled); 461 DCHECK(request_handled);
461 } 462 }
462 NOTREACHED(); 463 NOTREACHED();
463 } 464 }
OLDNEW
« no previous file with comments | « components/nacl.gyp ('k') | components/nacl/loader/nonsfi/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698