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

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

Issue 216603002: Tell nacl_helper to use non SFI mode in HandleForkRequest (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
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 #include "components/nacl/loader/nacl_listener.h" 5 #include "components/nacl/loader/nacl_listener.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #if defined(OS_POSIX) 10 #if defined(OS_POSIX)
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 193 }
194 194
195 private: 195 private:
196 // The listener never dies, otherwise this might be a dangling reference. 196 // The listener never dies, otherwise this might be a dangling reference.
197 NaClListener* listener_; 197 NaClListener* listener_;
198 }; 198 };
199 199
200 200
201 NaClListener::NaClListener() : shutdown_event_(true, false), 201 NaClListener::NaClListener() : shutdown_event_(true, false),
202 io_thread_("NaCl_IOThread"), 202 io_thread_("NaCl_IOThread"),
203 uses_nonsfi_mode_(false),
203 #if defined(OS_LINUX) 204 #if defined(OS_LINUX)
204 prereserved_sandbox_size_(0), 205 prereserved_sandbox_size_(0),
205 #endif 206 #endif
206 #if defined(OS_POSIX) 207 #if defined(OS_POSIX)
207 number_of_cores_(-1), // unknown/error 208 number_of_cores_(-1), // unknown/error
208 #endif 209 #endif
209 main_loop_(NULL) { 210 main_loop_(NULL) {
210 io_thread_.StartWithOptions( 211 io_thread_.StartWithOptions(
211 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 212 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
212 #if defined(OS_WIN) 213 #if defined(OS_WIN)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { 251 bool NaClListener::OnMessageReceived(const IPC::Message& msg) {
251 bool handled = true; 252 bool handled = true;
252 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) 253 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg)
253 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStart) 254 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStart)
254 IPC_MESSAGE_UNHANDLED(handled = false) 255 IPC_MESSAGE_UNHANDLED(handled = false)
255 IPC_END_MESSAGE_MAP() 256 IPC_END_MESSAGE_MAP()
256 return handled; 257 return handled;
257 } 258 }
258 259
259 void NaClListener::OnStart(const nacl::NaClStartParams& params) { 260 void NaClListener::OnStart(const nacl::NaClStartParams& params) {
261 #if !defined(OS_LINUX)
262 CHECK(!uses_nonsfi_mode_) << "Non-SFI NaCl is only supported on Linux";
263 #endif
260 #if defined(OS_LINUX) || defined(OS_MACOSX) 264 #if defined(OS_LINUX) || defined(OS_MACOSX)
261 int urandom_fd = dup(base::GetUrandomFD()); 265 int urandom_fd = dup(base::GetUrandomFD());
262 if (urandom_fd < 0) { 266 if (urandom_fd < 0) {
263 LOG(ERROR) << "Failed to dup() the urandom FD"; 267 LOG(ERROR) << "Failed to dup() the urandom FD";
264 return; 268 return;
265 } 269 }
266 NaClChromeMainSetUrandomFd(urandom_fd); 270 NaClChromeMainSetUrandomFd(urandom_fd);
267 #endif 271 #endif
268 272
269 NaClChromeMainInit(); 273 NaClChromeMainInit();
270 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); 274 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate();
271 if (args == NULL) { 275 if (args == NULL) {
272 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; 276 LOG(ERROR) << "NaClChromeMainArgsCreate() failed";
273 return; 277 return;
274 } 278 }
275 279
276 struct NaClApp *nap = NaClAppCreate(); 280 struct NaClApp *nap = NaClAppCreate();
277 if (nap == NULL) { 281 if (nap == NULL) {
278 LOG(ERROR) << "NaClAppCreate() failed"; 282 LOG(ERROR) << "NaClAppCreate() failed";
279 return; 283 return;
280 } 284 }
281 285
282 IPC::ChannelHandle browser_handle; 286 IPC::ChannelHandle browser_handle;
283 IPC::ChannelHandle ppapi_renderer_handle; 287 IPC::ChannelHandle ppapi_renderer_handle;
284 288
285 if (params.enable_ipc_proxy) { 289 if (params.enable_ipc_proxy) {
286 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); 290 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
287 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); 291 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
288 292
289 #if defined(OS_LINUX) 293 if (uses_nonsfi_mode_) {
Mark Seaborn 2014/04/02 00:22:22 You can't remove these #ifs. This code won't comp
hamaji 2014/04/02 03:20:44 Ah, I forgot sending a try job. Thanks for checkin
290 if (params.uses_nonsfi_mode) {
291 // In non-SFI mode, we neither intercept nor rewrite the message using 294 // In non-SFI mode, we neither intercept nor rewrite the message using
292 // NaClIPCAdapter, and the channels are connected between the plugin and 295 // NaClIPCAdapter, and the channels are connected between the plugin and
293 // the hosts directly. So, the IPC::Channel instances will be created in 296 // the hosts directly. So, the IPC::Channel instances will be created in
294 // the plugin side, because the IPC::Listener needs to live on the 297 // the plugin side, because the IPC::Listener needs to live on the
295 // plugin's main thread. However, on initialization (i.e. before loading 298 // plugin's main thread. However, on initialization (i.e. before loading
296 // the plugin binary), the FD needs to be passed to the hosts. So, here 299 // the plugin binary), the FD needs to be passed to the hosts. So, here
297 // we create raw FD pairs, and pass the client side FDs to the hosts, 300 // we create raw FD pairs, and pass the client side FDs to the hosts,
298 // and the server side FDs to the plugin. 301 // and the server side FDs to the plugin.
299 int browser_server_ppapi_fd; 302 int browser_server_ppapi_fd;
300 int browser_client_ppapi_fd; 303 int browser_client_ppapi_fd;
(...skipping 10 matching lines...) Expand all
311 // Set the plugin IPC channel FDs. 314 // Set the plugin IPC channel FDs.
312 SetIPCFileDescriptors( 315 SetIPCFileDescriptors(
313 browser_server_ppapi_fd, renderer_server_ppapi_fd); 316 browser_server_ppapi_fd, renderer_server_ppapi_fd);
314 317
315 // Send back to the client side IPC channel FD to the host. 318 // Send back to the client side IPC channel FD to the host.
316 browser_handle.socket = 319 browser_handle.socket =
317 base::FileDescriptor(browser_client_ppapi_fd, true); 320 base::FileDescriptor(browser_client_ppapi_fd, true);
318 ppapi_renderer_handle.socket = 321 ppapi_renderer_handle.socket =
319 base::FileDescriptor(renderer_client_ppapi_fd, true); 322 base::FileDescriptor(renderer_client_ppapi_fd, true);
320 } else { 323 } else {
321 #endif
322 // Create the PPAPI IPC channels between the NaCl IRT and the host 324 // Create the PPAPI IPC channels between the NaCl IRT and the host
323 // (browser/renderer) processes. The IRT uses these channels to 325 // (browser/renderer) processes. The IRT uses these channels to
324 // communicate with the host and to initialize the IPC dispatchers. 326 // communicate with the host and to initialize the IPC dispatchers.
325 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), 327 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(),
326 nap, NACL_CHROME_DESC_BASE); 328 nap, NACL_CHROME_DESC_BASE);
327 SetUpIPCAdapter(&ppapi_renderer_handle, io_thread_.message_loop_proxy(), 329 SetUpIPCAdapter(&ppapi_renderer_handle, io_thread_.message_loop_proxy(),
328 nap, NACL_CHROME_DESC_BASE + 1); 330 nap, NACL_CHROME_DESC_BASE + 1);
329 #if defined(OS_LINUX)
330 } 331 }
331 #endif
332 } 332 }
333 333
334 // The argument passed to GenerateVerifiedChannelID() here MUST be "nacl". 334 // The argument passed to GenerateVerifiedChannelID() here MUST be "nacl".
335 // Using an alternate channel name prevents the pipe from being created on 335 // Using an alternate channel name prevents the pipe from being created on
336 // Windows when the sandbox is enabled. 336 // Windows when the sandbox is enabled.
337 IPC::ChannelHandle trusted_renderer_handle = 337 IPC::ChannelHandle trusted_renderer_handle =
338 IPC::Channel::GenerateVerifiedChannelID("nacl"); 338 IPC::Channel::GenerateVerifiedChannelID("nacl");
339 trusted_listener_ = new NaClTrustedListener( 339 trusted_listener_ = new NaClTrustedListener(
340 trusted_renderer_handle, io_thread_.message_loop_proxy(), 340 trusted_renderer_handle, io_thread_.message_loop_proxy(),
341 &shutdown_event_); 341 &shutdown_event_);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 params.debug_stub_server_bound_socket); 413 params.debug_stub_server_bound_socket);
414 #endif 414 #endif
415 #if defined(OS_WIN) 415 #if defined(OS_WIN)
416 args->broker_duplicate_handle_func = BrokerDuplicateHandle; 416 args->broker_duplicate_handle_func = BrokerDuplicateHandle;
417 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; 417 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler;
418 #endif 418 #endif
419 #if defined(OS_LINUX) 419 #if defined(OS_LINUX)
420 args->prereserved_sandbox_size = prereserved_sandbox_size_; 420 args->prereserved_sandbox_size = prereserved_sandbox_size_;
421 #endif 421 #endif
422 422
423 #if defined(OS_LINUX) 423 if (uses_nonsfi_mode_) {
424 if (params.uses_nonsfi_mode) {
425 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); 424 nacl::nonsfi::MainStart(args->imc_bootstrap_handle);
426 return; 425 return;
427 } 426 }
428 #endif
429 NaClChromeMainStartApp(nap, args); 427 NaClChromeMainStartApp(nap, args);
430 NOTREACHED(); 428 NOTREACHED();
431 } 429 }
OLDNEW
« no previous file with comments | « components/nacl/loader/nacl_listener.h ('k') | components/nacl/zygote/nacl_fork_delegate_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698