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 <string.h> | 7 #include <string.h> |
8 | 8 |
9 /* | 9 /* |
10 * NaCl Simple/secure ELF loader (NaCl SEL). | 10 * NaCl Simple/secure ELF loader (NaCl SEL). |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "native_client/src/trusted/service_runtime/include/sys/time.h" | 44 #include "native_client/src/trusted/service_runtime/include/sys/time.h" |
45 #include "native_client/src/trusted/service_runtime/nacl_app.h" | 45 #include "native_client/src/trusted/service_runtime/nacl_app.h" |
46 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h" | 46 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h" |
47 #include "native_client/src/trusted/service_runtime/nacl_desc_effector_ldr.h" | 47 #include "native_client/src/trusted/service_runtime/nacl_desc_effector_ldr.h" |
48 #include "native_client/src/trusted/service_runtime/nacl_globals.h" | 48 #include "native_client/src/trusted/service_runtime/nacl_globals.h" |
49 #include "native_client/src/trusted/service_runtime/nacl_resource.h" | 49 #include "native_client/src/trusted/service_runtime/nacl_resource.h" |
50 #include "native_client/src/trusted/service_runtime/nacl_reverse_quota_interface
.h" | 50 #include "native_client/src/trusted/service_runtime/nacl_reverse_quota_interface
.h" |
51 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h" | 51 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h" |
52 #include "native_client/src/trusted/service_runtime/nacl_syscall_handlers.h" | 52 #include "native_client/src/trusted/service_runtime/nacl_syscall_handlers.h" |
53 #include "native_client/src/trusted/service_runtime/nacl_valgrind_hooks.h" | 53 #include "native_client/src/trusted/service_runtime/nacl_valgrind_hooks.h" |
54 #include "native_client/src/trusted/service_runtime/name_service/name_service.h" | |
55 #include "native_client/src/trusted/service_runtime/sel_addrspace.h" | 54 #include "native_client/src/trusted/service_runtime/sel_addrspace.h" |
56 #include "native_client/src/trusted/service_runtime/sel_ldr.h" | 55 #include "native_client/src/trusted/service_runtime/sel_ldr.h" |
57 #include "native_client/src/trusted/service_runtime/sel_memory.h" | 56 #include "native_client/src/trusted/service_runtime/sel_memory.h" |
58 #include "native_client/src/trusted/service_runtime/sel_ldr_thread_interface.h" | 57 #include "native_client/src/trusted/service_runtime/sel_ldr_thread_interface.h" |
59 #include "native_client/src/trusted/simple_service/nacl_simple_rservice.h" | 58 #include "native_client/src/trusted/simple_service/nacl_simple_rservice.h" |
60 #include "native_client/src/trusted/simple_service/nacl_simple_service.h" | 59 #include "native_client/src/trusted/simple_service/nacl_simple_service.h" |
61 #include "native_client/src/trusted/threading/nacl_thread_interface.h" | 60 #include "native_client/src/trusted/threading/nacl_thread_interface.h" |
62 #include "native_client/src/trusted/validator/rich_file_info.h" | 61 #include "native_client/src/trusted/validator/rich_file_info.h" |
63 #include "native_client/src/trusted/validator/validation_cache.h" | 62 #include "native_client/src/trusted/validator/validation_cache.h" |
64 | 63 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 #endif | 200 #endif |
202 | 201 |
203 nap->syscall_table = table; | 202 nap->syscall_table = table; |
204 | 203 |
205 nap->runtime_host_interface = NULL; | 204 nap->runtime_host_interface = NULL; |
206 nap->desc_quota_interface = NULL; | 205 nap->desc_quota_interface = NULL; |
207 | 206 |
208 nap->module_initialization_state = NACL_MODULE_UNINITIALIZED; | 207 nap->module_initialization_state = NACL_MODULE_UNINITIALIZED; |
209 nap->module_load_status = LOAD_OK; | 208 nap->module_load_status = LOAD_OK; |
210 | 209 |
211 nap->name_service = (struct NaClNameService *) malloc( | |
212 sizeof *nap->name_service); | |
213 if (NULL == nap->name_service) { | |
214 goto cleanup_cv; | |
215 } | |
216 if (!NaClNameServiceCtor(nap->name_service, | |
217 NaClAddrSpSquattingThreadIfFactoryFunction, | |
218 (void *) nap)) { | |
219 free(nap->name_service); | |
220 goto cleanup_cv; | |
221 } | |
222 nap->name_service_conn_cap = NaClDescRef(nap->name_service-> | |
223 base.base.bound_and_cap[1]); | |
224 | |
225 nap->ignore_validator_result = 0; | 210 nap->ignore_validator_result = 0; |
226 nap->skip_validator = 0; | 211 nap->skip_validator = 0; |
227 nap->validator_stub_out_mode = 0; | 212 nap->validator_stub_out_mode = 0; |
228 | 213 |
229 if (IsEnvironmentVariableSet("NACL_DANGEROUS_ENABLE_FILE_ACCESS")) { | 214 if (IsEnvironmentVariableSet("NACL_DANGEROUS_ENABLE_FILE_ACCESS")) { |
230 NaClInsecurelyBypassAllAclChecks(); | 215 NaClInsecurelyBypassAllAclChecks(); |
231 NaClLog(LOG_INFO, "DANGER: ENABLED FILE ACCESS\n"); | 216 NaClLog(LOG_INFO, "DANGER: ENABLED FILE ACCESS\n"); |
232 } | 217 } |
233 | 218 |
234 nap->enable_list_mappings = 0; | 219 nap->enable_list_mappings = 0; |
235 if (IsEnvironmentVariableSet("NACL_DANGEROUS_ENABLE_LIST_MAPPINGS")) { | 220 if (IsEnvironmentVariableSet("NACL_DANGEROUS_ENABLE_LIST_MAPPINGS")) { |
236 /* | 221 /* |
237 * This syscall is not actually know to be dangerous, but is not yet | 222 * This syscall is not actually know to be dangerous, but is not yet |
238 * exposed by our public API. | 223 * exposed by our public API. |
239 */ | 224 */ |
240 NaClLog(LOG_INFO, "DANGER: ENABLED LIST_MAPPINGS\n"); | 225 NaClLog(LOG_INFO, "DANGER: ENABLED LIST_MAPPINGS\n"); |
241 nap->enable_list_mappings = 1; | 226 nap->enable_list_mappings = 1; |
242 } | 227 } |
243 nap->pnacl_mode = 0; | 228 nap->pnacl_mode = 0; |
244 | 229 |
245 if (!NaClMutexCtor(&nap->threads_mu)) { | 230 if (!NaClMutexCtor(&nap->threads_mu)) { |
246 goto cleanup_name_service; | 231 goto cleanup_cv; |
247 } | 232 } |
248 nap->num_threads = 0; | 233 nap->num_threads = 0; |
249 if (!NaClFastMutexCtor(&nap->desc_mu)) { | 234 if (!NaClFastMutexCtor(&nap->desc_mu)) { |
250 goto cleanup_threads_mu; | 235 goto cleanup_threads_mu; |
251 } | 236 } |
252 | 237 |
253 nap->running = 0; | 238 nap->running = 0; |
254 nap->exit_status = -1; | 239 nap->exit_status = -1; |
255 | 240 |
256 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32 | 241 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 nap->futex_wait_list_head.prev = &nap->futex_wait_list_head; | 287 nap->futex_wait_list_head.prev = &nap->futex_wait_list_head; |
303 | 288 |
304 return 1; | 289 return 1; |
305 | 290 |
306 cleanup_exception_mu: | 291 cleanup_exception_mu: |
307 NaClMutexDtor(&nap->exception_mu); | 292 NaClMutexDtor(&nap->exception_mu); |
308 cleanup_desc_mu: | 293 cleanup_desc_mu: |
309 NaClFastMutexDtor(&nap->desc_mu); | 294 NaClFastMutexDtor(&nap->desc_mu); |
310 cleanup_threads_mu: | 295 cleanup_threads_mu: |
311 NaClMutexDtor(&nap->threads_mu); | 296 NaClMutexDtor(&nap->threads_mu); |
312 cleanup_name_service: | |
313 NaClDescUnref(nap->name_service_conn_cap); | |
314 NaClRefCountUnref((struct NaClRefCount *) nap->name_service); | |
315 cleanup_cv: | 297 cleanup_cv: |
316 NaClCondVarDtor(&nap->cv); | 298 NaClCondVarDtor(&nap->cv); |
317 cleanup_mu: | 299 cleanup_mu: |
318 NaClMutexDtor(&nap->mu); | 300 NaClMutexDtor(&nap->mu); |
319 cleanup_dynamic_load_mutex: | 301 cleanup_dynamic_load_mutex: |
320 NaClMutexDtor(&nap->dynamic_load_mutex); | 302 NaClMutexDtor(&nap->dynamic_load_mutex); |
321 cleanup_effp_free: | 303 cleanup_effp_free: |
322 free(nap->effp); | 304 free(nap->effp); |
323 cleanup_mem_io_regions: | 305 cleanup_mem_io_regions: |
324 NaClIntervalMultisetDelete(nap->mem_io_regions); | 306 NaClIntervalMultisetDelete(nap->mem_io_regions); |
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 nacl_global_xlate_base = mem_start; | 1279 nacl_global_xlate_base = mem_start; |
1298 | 1280 |
1299 NaClSandboxMemoryStartForValgrind(mem_start); | 1281 NaClSandboxMemoryStartForValgrind(mem_start); |
1300 | 1282 |
1301 _ovly_debug_event(); | 1283 _ovly_debug_event(); |
1302 } | 1284 } |
1303 | 1285 |
1304 void NaClGdbHook(struct NaClApp const *nap) { | 1286 void NaClGdbHook(struct NaClApp const *nap) { |
1305 StopForDebuggerInit(nap->mem_start); | 1287 StopForDebuggerInit(nap->mem_start); |
1306 } | 1288 } |
OLD | NEW |