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

Side by Side Diff: components/nacl/loader/sandbox_linux/nacl_sandbox_linux.cc

Issue 888903004: Non-SFI mode:Suid sandbox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/nacl/loader/sandbox_linux/nacl_sandbox_linux.h" 5 #include "components/nacl/loader/sandbox_linux/nacl_sandbox_linux.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // the setuid sandbox model. 89 // the setuid sandbox model.
90 CHECK(!HasOpenDirectory()); 90 CHECK(!HasOpenDirectory());
91 91
92 // Get sandboxed. 92 // Get sandboxed.
93 CHECK(setuid_sandbox_client_->ChrootMe()); 93 CHECK(setuid_sandbox_client_->ChrootMe());
94 CHECK(IsSandboxed()); 94 CHECK(IsSandboxed());
95 layer_one_enabled_ = true; 95 layer_one_enabled_ = true;
96 } 96 }
97 } 97 }
98 98
99 #if !defined(OS_NACL_NONSFI)
100 // Currently Layer-two sandbox is not yet supported on nacl_helper_nonsfi.
101 // TODO(hidehiko): Enable the sandbox.
99 void NaClSandbox::CheckForExpectedNumberOfOpenFds() { 102 void NaClSandbox::CheckForExpectedNumberOfOpenFds() {
Mark Seaborn 2015/02/06 20:15:03 Technically, CheckForExpectedNumberOfOpenFds() isn
hidehiko 2015/03/02 19:16:25 No, but it is only called from InitializeLayerTwoS
100 if (setuid_sandbox_client_->IsSuidSandboxChild()) { 103 if (setuid_sandbox_client_->IsSuidSandboxChild()) {
101 // We expect to have the following FDs open: 104 // We expect to have the following FDs open:
102 // 1-3) stdin, stdout, stderr. 105 // 1-3) stdin, stdout, stderr.
103 // 4) The /dev/urandom FD used by base::GetUrandomFD(). 106 // 4) The /dev/urandom FD used by base::GetUrandomFD().
104 // 5) A dummy pipe FD used to overwrite kSandboxIPCChannel. 107 // 5) A dummy pipe FD used to overwrite kSandboxIPCChannel.
105 // 6) The socket created by the SUID sandbox helper, used by ChrootMe(). 108 // 6) The socket created by the SUID sandbox helper, used by ChrootMe().
106 // After ChrootMe(), this is no longer connected to anything. 109 // After ChrootMe(), this is no longer connected to anything.
107 // (Only present when running under the SUID sandbox.) 110 // (Only present when running under the SUID sandbox.)
108 // 7) The socket for the Chrome IPC channel that's connected to the 111 // 7) The socket for the Chrome IPC channel that's connected to the
109 // browser process, kPrimaryIPCChannel. 112 // browser process, kPrimaryIPCChannel.
(...skipping 14 matching lines...) Expand all
124 base::ScopedFD proc_self_task(GetProcSelfTask(proc_fd_.get())); 127 base::ScopedFD proc_self_task(GetProcSelfTask(proc_fd_.get()));
125 128
126 if (uses_nonsfi_mode) { 129 if (uses_nonsfi_mode) {
127 layer_two_enabled_ = 130 layer_two_enabled_ =
128 nacl::nonsfi::InitializeBPFSandbox(proc_self_task.Pass()); 131 nacl::nonsfi::InitializeBPFSandbox(proc_self_task.Pass());
129 layer_two_is_nonsfi_ = true; 132 layer_two_is_nonsfi_ = true;
130 } else { 133 } else {
131 layer_two_enabled_ = nacl::InitializeBPFSandbox(proc_self_task.Pass()); 134 layer_two_enabled_ = nacl::InitializeBPFSandbox(proc_self_task.Pass());
132 } 135 }
133 } 136 }
137 #endif // OS_NACL_NONSFI
134 138
135 void NaClSandbox::SealLayerOneSandbox() { 139 void NaClSandbox::SealLayerOneSandbox() {
136 if (!layer_two_enabled_) { 140 if (!layer_two_enabled_) {
137 // If nothing prevents us, check that there is no superfluous directory 141 // If nothing prevents us, check that there is no superfluous directory
138 // open. 142 // open.
139 CHECK(!HasOpenDirectory()); 143 CHECK(!HasOpenDirectory());
140 } 144 }
141 proc_fd_.reset(); 145 proc_fd_.reset();
142 layer_one_sealed_ = true; 146 layer_one_sealed_ = true;
143 } 147 }
(...skipping 11 matching lines...) Expand all
155 159
156 if (!layer_one_enabled_ || !layer_one_sealed_) { 160 if (!layer_one_enabled_ || !layer_one_sealed_) {
157 static const char kNoSuidMsg[] = 161 static const char kNoSuidMsg[] =
158 "The SUID sandbox is not engaged for NaCl:"; 162 "The SUID sandbox is not engaged for NaCl:";
159 if (can_be_no_sandbox) 163 if (can_be_no_sandbox)
160 LOG(ERROR) << kNoSuidMsg << kItIsDangerousMsg; 164 LOG(ERROR) << kNoSuidMsg << kItIsDangerousMsg;
161 else 165 else
162 LOG(FATAL) << kNoSuidMsg << kItIsNotAllowedMsg; 166 LOG(FATAL) << kNoSuidMsg << kItIsNotAllowedMsg;
163 } 167 }
164 168
169 #if !defined(OS_NACL_NONSFI)
170 // Currently Layer-two sandbox is not yet supported on nacl_helper_nonsfi.
171 // TODO(hidehiko): Enable the sandbox.
165 if (!layer_two_enabled_) { 172 if (!layer_two_enabled_) {
166 static const char kNoBpfMsg[] = 173 static const char kNoBpfMsg[] =
167 "The seccomp-bpf sandbox is not engaged for NaCl:"; 174 "The seccomp-bpf sandbox is not engaged for NaCl:";
168 if (can_be_no_sandbox) 175 if (can_be_no_sandbox)
169 LOG(ERROR) << kNoBpfMsg << kItIsDangerousMsg; 176 LOG(ERROR) << kNoBpfMsg << kItIsDangerousMsg;
170 else 177 else
171 LOG(FATAL) << kNoBpfMsg << kItIsNotAllowedMsg; 178 LOG(FATAL) << kNoBpfMsg << kItIsNotAllowedMsg;
172 } 179 }
180 #endif
173 } 181 }
174 182
175 } // namespace nacl 183 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698