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

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

Issue 196793023: Add seccomp sandbox for non-SFI NaCl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 | Annotate | Revision Log
« 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 13 matching lines...) Expand all
24 #include "base/logging.h" 24 #include "base/logging.h"
25 #include "base/message_loop/message_loop.h" 25 #include "base/message_loop/message_loop.h"
26 #include "base/posix/eintr_wrapper.h" 26 #include "base/posix/eintr_wrapper.h"
27 #include "base/posix/global_descriptors.h" 27 #include "base/posix/global_descriptors.h"
28 #include "base/posix/unix_domain_socket_linux.h" 28 #include "base/posix/unix_domain_socket_linux.h"
29 #include "base/process/kill.h" 29 #include "base/process/kill.h"
30 #include "base/rand_util.h" 30 #include "base/rand_util.h"
31 #include "components/nacl/common/nacl_switches.h" 31 #include "components/nacl/common/nacl_switches.h"
32 #include "components/nacl/loader/nacl_listener.h" 32 #include "components/nacl/loader/nacl_listener.h"
33 #include "components/nacl/loader/nacl_sandbox_linux.h" 33 #include "components/nacl/loader/nacl_sandbox_linux.h"
34 #include "components/nacl/loader/nonsfi/nonsfi_sandbox.h"
34 #include "content/public/common/zygote_fork_delegate_linux.h" 35 #include "content/public/common/zygote_fork_delegate_linux.h"
35 #include "crypto/nss_util.h" 36 #include "crypto/nss_util.h"
36 #include "ipc/ipc_descriptors.h" 37 #include "ipc/ipc_descriptors.h"
37 #include "ipc/ipc_switches.h" 38 #include "ipc/ipc_switches.h"
38 #include "sandbox/linux/services/libc_urandom_override.h" 39 #include "sandbox/linux/services/libc_urandom_override.h"
39 40
40 namespace { 41 namespace {
41 42
42 struct NaClLoaderSystemInfo { 43 struct NaClLoaderSystemInfo {
43 size_t prereserved_sandbox_size; 44 size_t prereserved_sandbox_size;
(...skipping 14 matching lines...) Expand all
58 if (uses_nonsfi_mode) { 59 if (uses_nonsfi_mode) {
59 const bool can_be_no_sandbox = CommandLine::ForCurrentProcess()->HasSwitch( 60 const bool can_be_no_sandbox = CommandLine::ForCurrentProcess()->HasSwitch(
60 switches::kNaClDangerousNoSandboxNonSfi); 61 switches::kNaClDangerousNoSandboxNonSfi);
61 const bool setuid_sandbox_enabled = IsSandboxed(); 62 const bool setuid_sandbox_enabled = IsSandboxed();
62 if (!setuid_sandbox_enabled) { 63 if (!setuid_sandbox_enabled) {
63 if (can_be_no_sandbox) 64 if (can_be_no_sandbox)
64 LOG(ERROR) << "DANGEROUS: Running non-SFI NaCl without SUID sandbox!"; 65 LOG(ERROR) << "DANGEROUS: Running non-SFI NaCl without SUID sandbox!";
65 else 66 else
66 LOG(FATAL) << "SUID sandbox is mandatory for non-SFI NaCl"; 67 LOG(FATAL) << "SUID sandbox is mandatory for non-SFI NaCl";
67 } 68 }
68 const bool bpf_sandbox_initialized = InitializeBPFSandbox(); 69 const bool bpf_sandbox_initialized = nacl::nonsfi::InitializeBPFSandbox();
69 if (!bpf_sandbox_initialized) { 70 if (!bpf_sandbox_initialized) {
70 if (can_be_no_sandbox) { 71 if (can_be_no_sandbox) {
71 LOG(ERROR) 72 LOG(ERROR)
72 << "DANGEROUS: Running non-SFI NaCl without seccomp-bpf sandbox!"; 73 << "DANGEROUS: Running non-SFI NaCl without seccomp-bpf sandbox!";
73 } else { 74 } else {
74 LOG(FATAL) << "Could not initialize NaCl's second " 75 LOG(FATAL) << "Could not initialize NaCl's second "
75 << "layer sandbox (seccomp-bpf) for non-SFI mode."; 76 << "layer sandbox (seccomp-bpf) for non-SFI mode.";
76 } 77 }
77 } 78 }
78 } else { 79 } else {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // Now handle requests from the Zygote. 423 // Now handle requests from the Zygote.
423 while (true) { 424 while (true) {
424 bool request_handled = HandleZygoteRequest(kNaClZygoteDescriptor, 425 bool request_handled = HandleZygoteRequest(kNaClZygoteDescriptor,
425 system_info); 426 system_info);
426 // Do not turn this into a CHECK() without thinking about robustness 427 // Do not turn this into a CHECK() without thinking about robustness
427 // against malicious IPC requests. 428 // against malicious IPC requests.
428 DCHECK(request_handled); 429 DCHECK(request_handled);
429 } 430 }
430 NOTREACHED(); 431 NOTREACHED();
431 } 432 }
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