Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "native_client/src/trusted/service_runtime/sel_main_chrome.h" | 7 #include "native_client/src/trusted/service_runtime/sel_main_chrome.h" |
| 8 | 8 |
| 9 #include "native_client/src/include/portability.h" | 9 #include "native_client/src/include/portability.h" |
| 10 #include "native_client/src/include/portability_io.h" | 10 #include "native_client/src/include/portability_io.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 #include "native_client/src/trusted/service_runtime/nacl_bootstrap_channel_error _reporter.h" | 34 #include "native_client/src/trusted/service_runtime/nacl_bootstrap_channel_error _reporter.h" |
| 35 #include "native_client/src/trusted/service_runtime/nacl_error_log_hook.h" | 35 #include "native_client/src/trusted/service_runtime/nacl_error_log_hook.h" |
| 36 #include "native_client/src/trusted/service_runtime/nacl_globals.h" | 36 #include "native_client/src/trusted/service_runtime/nacl_globals.h" |
| 37 #include "native_client/src/trusted/service_runtime/nacl_debug_init.h" | 37 #include "native_client/src/trusted/service_runtime/nacl_debug_init.h" |
| 38 #include "native_client/src/trusted/service_runtime/nacl_signal.h" | 38 #include "native_client/src/trusted/service_runtime/nacl_signal.h" |
| 39 #include "native_client/src/trusted/service_runtime/osx/mach_exception_handler.h " | 39 #include "native_client/src/trusted/service_runtime/osx/mach_exception_handler.h " |
| 40 #include "native_client/src/trusted/service_runtime/sel_addrspace.h" | 40 #include "native_client/src/trusted/service_runtime/sel_addrspace.h" |
| 41 #include "native_client/src/trusted/service_runtime/sel_ldr.h" | 41 #include "native_client/src/trusted/service_runtime/sel_ldr.h" |
| 42 #include "native_client/src/trusted/service_runtime/sel_qualify.h" | 42 #include "native_client/src/trusted/service_runtime/sel_qualify.h" |
| 43 #include "native_client/src/trusted/service_runtime/win/exception_patch/ntdll_pa tch.h" | 43 #include "native_client/src/trusted/service_runtime/win/exception_patch/ntdll_pa tch.h" |
| 44 #include "native_client/src/trusted/validator/validation_metadata.h" | |
| 44 | 45 |
| 45 struct NaClChromeMainArgs *NaClChromeMainArgsCreate(void) { | 46 struct NaClChromeMainArgs *NaClChromeMainArgsCreate(void) { |
| 46 struct NaClChromeMainArgs *args = malloc(sizeof(*args)); | 47 struct NaClChromeMainArgs *args = malloc(sizeof(*args)); |
| 47 if (args == NULL) | 48 if (args == NULL) |
| 48 return NULL; | 49 return NULL; |
| 49 args->imc_bootstrap_handle = NACL_INVALID_HANDLE; | 50 args->imc_bootstrap_handle = NACL_INVALID_HANDLE; |
| 50 args->irt_fd = -1; | 51 args->irt_fd = -1; |
| 51 args->initial_ipc_desc = NULL; | 52 args->initial_ipc_desc = NULL; |
| 52 args->enable_exception_handling = 0; | 53 args->enable_exception_handling = 0; |
| 53 args->enable_debug_stub = 0; | 54 args->enable_debug_stub = 0; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 70 /* | 71 /* |
| 71 * Initialize NaClLog so that Chromium can call | 72 * Initialize NaClLog so that Chromium can call |
| 72 * NaClDescMakeCustomDesc() between calling | 73 * NaClDescMakeCustomDesc() between calling |
| 73 * NaClChromeMainArgsCreate() and NaClChromeMainStart(). | 74 * NaClChromeMainArgsCreate() and NaClChromeMainStart(). |
| 74 */ | 75 */ |
| 75 NaClLogModuleInit(); | 76 NaClLogModuleInit(); |
| 76 | 77 |
| 77 return args; | 78 return args; |
| 78 } | 79 } |
| 79 | 80 |
| 81 static char kFakeIrtName[] = "\0IRT"; | |
| 82 | |
| 83 static void ValidationMetadataForFD(int file_desc, | |
| 84 const char* file_name, | |
| 85 size_t file_name_length, | |
| 86 struct NaClValidationMetadata *metadata) { | |
| 87 struct NaClHostDesc wrapper; | |
| 88 nacl_host_stat_t stat; | |
| 89 | |
| 90 memset(metadata, 0, sizeof(*metadata)); | |
| 91 wrapper.d = file_desc; | |
| 92 if(!NaClHostDescFstat(&wrapper, &stat)) { | |
| 93 metadata->identity_type = NaClCodeIdentityFile; | |
| 94 /* TODO(ncbray) plumb the real filename in from Chrome. */ | |
| 95 metadata->file_name = file_name; | |
| 96 metadata->file_name_length = file_name_length; | |
| 97 metadata->file_size = stat.st_size; | |
| 98 metadata->mtime = stat.st_mtime; | |
| 99 /* TODO(ncbray) dev / ino where available. */ | |
| 100 } | |
| 101 } | |
| 102 | |
| 80 static void NaClLoadIrt(struct NaClApp *nap, int irt_fd) { | 103 static void NaClLoadIrt(struct NaClApp *nap, int irt_fd) { |
| 81 int file_desc; | 104 int file_desc; |
| 82 struct GioPio gio_pio; | 105 struct GioPio gio_pio; |
| 83 struct Gio *gio_desc; | 106 struct Gio *gio_desc; |
| 107 struct NaClValidationMetadata metadata; | |
| 84 NaClErrorCode errcode; | 108 NaClErrorCode errcode; |
| 85 | 109 |
| 86 if (irt_fd == -1) { | 110 if (irt_fd == -1) { |
| 87 NaClLog(LOG_FATAL, "NaClLoadIrt: Integrated runtime (IRT) not present.\n"); | 111 NaClLog(LOG_FATAL, "NaClLoadIrt: Integrated runtime (IRT) not present.\n"); |
| 88 } | 112 } |
| 89 | 113 |
| 90 file_desc = DUP(irt_fd); | 114 file_desc = DUP(irt_fd); |
| 91 if (file_desc < 0) { | 115 if (file_desc < 0) { |
| 92 NaClLog(LOG_FATAL, "NaClLoadIrt: Failed to dup() file descriptor\n"); | 116 NaClLog(LOG_FATAL, "NaClLoadIrt: Failed to dup() file descriptor\n"); |
| 93 } | 117 } |
| 94 | 118 |
| 119 ValidationMetadataForFD(file_desc, kFakeIrtName, sizeof(kFakeIrtName), | |
|
bsy
2013/03/28 00:11:49
just to be clearer, maybe a comment that the kFake
| |
| 120 &metadata); | |
| 121 | |
| 95 /* | 122 /* |
| 96 * The GioPio type is safe to use when this file descriptor is shared | 123 * The GioPio type is safe to use when this file descriptor is shared |
| 97 * with other processes, because it does not use the shared file position. | 124 * with other processes, because it does not use the shared file position. |
| 98 */ | 125 */ |
| 99 if (!GioPioCtor(&gio_pio, file_desc)) { | 126 if (!GioPioCtor(&gio_pio, file_desc)) { |
| 100 NaClLog(LOG_FATAL, "NaClLoadIrt: Failed to create Gio wrapper\n"); | 127 NaClLog(LOG_FATAL, "NaClLoadIrt: Failed to create Gio wrapper\n"); |
| 101 } | 128 } |
| 102 gio_desc = (struct Gio *) &gio_pio; | 129 gio_desc = (struct Gio *) &gio_pio; |
| 103 | 130 |
| 104 errcode = NaClAppLoadFileDynamically(nap, gio_desc); | 131 errcode = NaClAppLoadFileDynamically(nap, gio_desc, &metadata); |
| 105 if (errcode != LOAD_OK) { | 132 if (errcode != LOAD_OK) { |
| 106 NaClLog(LOG_FATAL, | 133 NaClLog(LOG_FATAL, |
| 107 "NaClLoadIrt: Failed to load the integrated runtime (IRT): %s\n", | 134 "NaClLoadIrt: Failed to load the integrated runtime (IRT): %s\n", |
| 108 NaClErrorString(errcode)); | 135 NaClErrorString(errcode)); |
| 109 } | 136 } |
| 110 | 137 |
| 111 (*NACL_VTBL(Gio, gio_desc)->Close)(gio_desc); | 138 (*NACL_VTBL(Gio, gio_desc)->Close)(gio_desc); |
| 112 (*NACL_VTBL(Gio, gio_desc)->Dtor)(gio_desc); | 139 (*NACL_VTBL(Gio, gio_desc)->Dtor)(gio_desc); |
| 113 } | 140 } |
| 114 | 141 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 * Instead, we wait for the hard-shutdown on the command channel. | 399 * Instead, we wait for the hard-shutdown on the command channel. |
| 373 */ | 400 */ |
| 374 if (LOAD_OK != errcode) { | 401 if (LOAD_OK != errcode) { |
| 375 NaClBlockIfCommandChannelExists(nap); | 402 NaClBlockIfCommandChannelExists(nap); |
| 376 } | 403 } |
| 377 | 404 |
| 378 NaClAllModulesFini(); | 405 NaClAllModulesFini(); |
| 379 | 406 |
| 380 NaClExit(ret_code); | 407 NaClExit(ret_code); |
| 381 } | 408 } |
| OLD | NEW |