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

Side by Side Diff: components/nacl/zygote/nacl_fork_delegate_linux.cc

Issue 279693002: Split NaCl SFI and non-SFI helpers into separate processes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
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 "components/nacl/zygote/nacl_fork_delegate_linux.h" 5 #include "components/nacl/zygote/nacl_fork_delegate_linux.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <sys/resource.h> 9 #include <sys/resource.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (msg_len <= 0) { 101 if (msg_len <= 0) {
102 LOG(ERROR) << "SendIPCRequestAndReadReply: RecvMsg failed"; 102 LOG(ERROR) << "SendIPCRequestAndReadReply: RecvMsg failed";
103 return false; 103 return false;
104 } 104 }
105 *reply_size = msg_len; 105 *reply_size = msg_len;
106 return true; 106 return true;
107 } 107 }
108 108
109 } // namespace. 109 } // namespace.
110 110
111 NaClForkDelegate::NaClForkDelegate() 111 NaClForkDelegate::NaClForkDelegate(bool nonsfi_mode)
112 : status_(kNaClHelperUnused), 112 : nonsfi_mode_(nonsfi_mode), status_(kNaClHelperUnused), fd_(-1) {
113 fd_(-1) {} 113 }
114 114
115 void NaClForkDelegate::Init(const int sandboxdesc, 115 void NaClForkDelegate::Init(const int sandboxdesc,
116 const bool enable_layer1_sandbox) { 116 const bool enable_layer1_sandbox) {
117 VLOG(1) << "NaClForkDelegate::Init()"; 117 VLOG(1) << "NaClForkDelegate::Init()";
118 int fds[2]; 118 int fds[2];
119 119
120 scoped_ptr<sandbox::SetuidSandboxClient> setuid_sandbox_client( 120 scoped_ptr<sandbox::SetuidSandboxClient> setuid_sandbox_client(
121 sandbox::SetuidSandboxClient::Create()); 121 sandbox::SetuidSandboxClient::Create());
122 122
123 // For communications between the NaCl loader process and 123 // For communications between the NaCl loader process and
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // TODO(bradchen): Make this LOG(ERROR) when the NaCl helper 255 // TODO(bradchen): Make this LOG(ERROR) when the NaCl helper
256 // becomes the default. 256 // becomes the default.
257 fd_ = -1; 257 fd_ = -1;
258 if (IGNORE_EINTR(close(fds[0])) != 0) 258 if (IGNORE_EINTR(close(fds[0])) != 0)
259 LOG(ERROR) << "close(fds[0]) failed"; 259 LOG(ERROR) << "close(fds[0]) failed";
260 } 260 }
261 261
262 void NaClForkDelegate::InitialUMA(std::string* uma_name, 262 void NaClForkDelegate::InitialUMA(std::string* uma_name,
263 int* uma_sample, 263 int* uma_sample,
264 int* uma_boundary_value) { 264 int* uma_boundary_value) {
265 *uma_name = "NaCl.Client.Helper.InitState"; 265 *uma_name = nonsfi_mode_ ? "NaCl.Client.HelperNonSFI.InitState"
266 : "NaCl.Client.Helper.InitState";
266 *uma_sample = status_; 267 *uma_sample = status_;
267 *uma_boundary_value = kNaClHelperStatusBoundary; 268 *uma_boundary_value = kNaClHelperStatusBoundary;
268 } 269 }
269 270
270 NaClForkDelegate::~NaClForkDelegate() { 271 NaClForkDelegate::~NaClForkDelegate() {
271 // side effect of close: delegate process will terminate 272 // side effect of close: delegate process will terminate
272 if (status_ == kNaClHelperSuccess) { 273 if (status_ == kNaClHelperSuccess) {
273 if (IGNORE_EINTR(close(fd_)) != 0) 274 if (IGNORE_EINTR(close(fd_)) != 0)
274 LOG(ERROR) << "close(fd_) failed"; 275 LOG(ERROR) << "close(fd_) failed";
275 } 276 }
276 } 277 }
277 278
278 bool NaClForkDelegate::CanHelp(const std::string& process_type, 279 bool NaClForkDelegate::CanHelp(const std::string& process_type,
279 std::string* uma_name, 280 std::string* uma_name,
280 int* uma_sample, 281 int* uma_sample,
281 int* uma_boundary_value) { 282 int* uma_boundary_value) {
282 if (process_type != switches::kNaClLoaderProcess && 283 if (process_type != (nonsfi_mode_ ? switches::kNaClLoaderNonSfiProcess
jln (very slow on Chromium) 2014/05/09 20:51:20 This is hard to read. Maybe have an intermediate
mdempsky 2014/05/09 21:34:11 Done. (I named it helpable_process_type.)
283 process_type != switches::kNaClLoaderNonSfiProcess) 284 : switches::kNaClLoaderProcess))
284 return false; 285 return false;
285 *uma_name = "NaCl.Client.Helper.StateOnFork"; 286 *uma_name = nonsfi_mode_ ? "NaCl.Client.HelperNonSFI.StateOnFork"
287 : "NaCl.Client.Helper.StateOnFork";
286 *uma_sample = status_; 288 *uma_sample = status_;
287 *uma_boundary_value = kNaClHelperStatusBoundary; 289 *uma_boundary_value = kNaClHelperStatusBoundary;
288 return true; 290 return true;
289 } 291 }
290 292
291 pid_t NaClForkDelegate::Fork(const std::string& process_type, 293 pid_t NaClForkDelegate::Fork(const std::string& process_type,
292 const std::vector<int>& fds, 294 const std::vector<int>& fds,
293 const std::string& channel_id) { 295 const std::string& channel_id) {
294 VLOG(1) << "NaClForkDelegate::Fork"; 296 VLOG(1) << "NaClForkDelegate::Fork";
295 297
296 DCHECK(fds.size() == kNumPassedFDs); 298 DCHECK(fds.size() == kNumPassedFDs);
297 299
298 if (status_ != kNaClHelperSuccess) { 300 if (status_ != kNaClHelperSuccess) {
299 LOG(ERROR) << "Cannot launch NaCl process: nacl_helper failed to start"; 301 LOG(ERROR) << "Cannot launch NaCl process: nacl_helper failed to start";
300 return -1; 302 return -1;
301 } 303 }
302 304
303 // First, send a remote fork request. 305 // First, send a remote fork request.
304 Pickle write_pickle; 306 Pickle write_pickle;
305 write_pickle.WriteInt(nacl::kNaClForkRequest); 307 write_pickle.WriteInt(nacl::kNaClForkRequest);
306 // TODO(hamaji): When we split the helper binary for non-SFI mode 308 write_pickle.WriteBool(nonsfi_mode_);
307 // from nacl_helper, stop sending this information.
308 const bool uses_nonsfi_mode =
309 process_type == switches::kNaClLoaderNonSfiProcess;
310 write_pickle.WriteBool(uses_nonsfi_mode);
311 write_pickle.WriteString(channel_id); 309 write_pickle.WriteString(channel_id);
312 310
313 char reply_buf[kNaClMaxIPCMessageLength]; 311 char reply_buf[kNaClMaxIPCMessageLength];
314 ssize_t reply_size = 0; 312 ssize_t reply_size = 0;
315 bool got_reply = 313 bool got_reply =
316 SendIPCRequestAndReadReply(fd_, fds, write_pickle, 314 SendIPCRequestAndReadReply(fd_, fds, write_pickle,
317 reply_buf, sizeof(reply_buf), &reply_size); 315 reply_buf, sizeof(reply_buf), &reply_size);
318 if (!got_reply) { 316 if (!got_reply) {
319 LOG(ERROR) << "Could not perform remote fork."; 317 LOG(ERROR) << "Could not perform remote fork.";
320 return -1; 318 return -1;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 int remote_exit_code; 366 int remote_exit_code;
369 if (!iter.ReadInt(&remote_exit_code)) { 367 if (!iter.ReadInt(&remote_exit_code)) {
370 LOG(ERROR) << "GetTerminationStatus: pickle failed"; 368 LOG(ERROR) << "GetTerminationStatus: pickle failed";
371 return false; 369 return false;
372 } 370 }
373 371
374 *status = static_cast<base::TerminationStatus>(termination_status); 372 *status = static_cast<base::TerminationStatus>(termination_status);
375 *exit_code = remote_exit_code; 373 *exit_code = remote_exit_code;
376 return true; 374 return true;
377 } 375 }
OLDNEW
« chrome/app/chrome_main_delegate.cc ('K') | « components/nacl/zygote/nacl_fork_delegate_linux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698