| 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/nacl_secure_service.h" | 7 #include "native_client/src/trusted/service_runtime/nacl_secure_service.h" |
| 8 | 8 |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| 11 #include "native_client/src/public/secure_service.h" | 11 #include "native_client/src/public/secure_service.h" |
| 12 | 12 |
| 13 #include "native_client/src/shared/platform/nacl_exit.h" | 13 #include "native_client/src/shared/platform/nacl_exit.h" |
| 14 #include "native_client/src/shared/platform/nacl_log.h" | 14 #include "native_client/src/shared/platform/nacl_log.h" |
| 15 #include "native_client/src/shared/platform/nacl_sync.h" | 15 #include "native_client/src/shared/platform/nacl_sync.h" |
| 16 #include "native_client/src/shared/platform/nacl_sync_checked.h" | 16 #include "native_client/src/shared/platform/nacl_sync_checked.h" |
| 17 #include "native_client/src/shared/srpc/nacl_srpc.h" | 17 #include "native_client/src/shared/srpc/nacl_srpc.h" |
| 18 | 18 |
| 19 #include "native_client/src/trusted/desc/nacl_desc_invalid.h" | 19 #include "native_client/src/trusted/desc/nacl_desc_invalid.h" |
| 20 #include "native_client/src/trusted/fault_injection/fault_injection.h" | 20 #include "native_client/src/trusted/fault_injection/fault_injection.h" |
| 21 #include "native_client/src/trusted/manifest_name_service_proxy/manifest_proxy.h
" | |
| 22 #include "native_client/src/trusted/simple_service/nacl_simple_service.h" | 21 #include "native_client/src/trusted/simple_service/nacl_simple_service.h" |
| 23 #include "native_client/src/trusted/service_runtime/include/sys/errno.h" | 22 #include "native_client/src/trusted/service_runtime/include/sys/errno.h" |
| 24 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" | 23 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" |
| 25 #include "native_client/src/trusted/service_runtime/nacl_app.h" | 24 #include "native_client/src/trusted/service_runtime/nacl_app.h" |
| 26 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" | 25 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" |
| 27 #include "native_client/src/trusted/service_runtime/nacl_reverse_host_interface.
h" | 26 #include "native_client/src/trusted/service_runtime/nacl_reverse_host_interface.
h" |
| 28 #include "native_client/src/trusted/service_runtime/nacl_reverse_quota_interface
.h" | 27 #include "native_client/src/trusted/service_runtime/nacl_reverse_quota_interface
.h" |
| 29 #include "native_client/src/trusted/service_runtime/nacl_signal.h" | 28 #include "native_client/src/trusted/service_runtime/nacl_signal.h" |
| 30 #include "native_client/src/trusted/service_runtime/sel_ldr.h" | 29 #include "native_client/src/trusted/service_runtime/sel_ldr.h" |
| 31 | 30 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 * actual thread that made the connection request using |conn| | 226 * actual thread that made the connection request using |conn| |
| 228 * received in the first connection. | 227 * received in the first connection. |
| 229 */ | 228 */ |
| 230 static void NaClSecureReverseClientCallback( | 229 static void NaClSecureReverseClientCallback( |
| 231 void *state, | 230 void *state, |
| 232 struct NaClThreadInterface *tif, | 231 struct NaClThreadInterface *tif, |
| 233 struct NaClDesc *new_conn) { | 232 struct NaClDesc *new_conn) { |
| 234 struct NaClSecureService *self = | 233 struct NaClSecureService *self = |
| 235 (struct NaClSecureService *) state; | 234 (struct NaClSecureService *) state; |
| 236 struct NaClApp *nap = self->nap; | 235 struct NaClApp *nap = self->nap; |
| 237 struct NaClManifestProxy *manifest_proxy; | |
| 238 struct NaClReverseHostInterface *reverse_host_interface; | 236 struct NaClReverseHostInterface *reverse_host_interface; |
| 239 struct NaClReverseQuotaInterface *reverse_quota_interface; | 237 struct NaClReverseQuotaInterface *reverse_quota_interface; |
| 240 UNREFERENCED_PARAMETER(tif); | 238 UNREFERENCED_PARAMETER(tif); |
| 241 | 239 |
| 242 NaClLog(4, | 240 NaClLog(4, |
| 243 ("Entered NaClSecureReverseClientCallback: self 0x%"NACL_PRIxPTR"," | 241 ("Entered NaClSecureReverseClientCallback: self 0x%"NACL_PRIxPTR"," |
| 244 " nap 0x%"NACL_PRIxPTR", new_conn 0x%"NACL_PRIxPTR"\n"), | 242 " nap 0x%"NACL_PRIxPTR", new_conn 0x%"NACL_PRIxPTR"\n"), |
| 245 (uintptr_t) self, (uintptr_t) nap, (uintptr_t) new_conn); | 243 (uintptr_t) self, (uintptr_t) nap, (uintptr_t) new_conn); |
| 246 | 244 |
| 247 NaClXMutexLock(&self->mu); | 245 NaClXMutexLock(&self->mu); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 self))) { | 283 self))) { |
| 286 NaClLog(LOG_FATAL, "Reverse quota interface ctor failed\n"); | 284 NaClLog(LOG_FATAL, "Reverse quota interface ctor failed\n"); |
| 287 goto cleanup_reverse_quota_interface; | 285 goto cleanup_reverse_quota_interface; |
| 288 } | 286 } |
| 289 NaClAppDescQuotaSetup(nap, (struct NaClDescQuotaInterface *) | 287 NaClAppDescQuotaSetup(nap, (struct NaClDescQuotaInterface *) |
| 290 reverse_quota_interface); | 288 reverse_quota_interface); |
| 291 | 289 |
| 292 NaClRefCountSafeUnref((struct NaClRefCount *) reverse_quota_interface); | 290 NaClRefCountSafeUnref((struct NaClRefCount *) reverse_quota_interface); |
| 293 reverse_quota_interface = NULL; | 291 reverse_quota_interface = NULL; |
| 294 | 292 |
| 295 manifest_proxy = (struct NaClManifestProxy *) | |
| 296 malloc(sizeof *manifest_proxy); | |
| 297 if (NULL == manifest_proxy || | |
| 298 !NaClManifestProxyCtor(manifest_proxy, | |
| 299 NaClAddrSpSquattingThreadIfFactoryFunction, | |
| 300 (void *) nap, | |
| 301 self)) { | |
| 302 NaClLog(LOG_FATAL, "Manifest proxy ctor failed\n"); | |
| 303 goto cleanup_manifest_proxy; | |
| 304 } | |
| 305 | |
| 306 /* | |
| 307 * NaClSimpleServiceStartServiceThread requires the nap->mu lock. | |
| 308 */ | |
| 309 if (!NaClSimpleServiceStartServiceThread((struct NaClSimpleService *) | |
| 310 manifest_proxy)) { | |
| 311 NaClLog(LOG_FATAL, "ManifestProxy start service failed\n"); | |
| 312 goto cleanup_manifest_proxy; | |
| 313 } | |
| 314 | |
| 315 NaClXMutexLock(&nap->mu); | |
| 316 (*NACL_VTBL(NaClNameService, nap->name_service)-> | |
| 317 CreateDescEntry)(nap->name_service, | |
| 318 "ManifestNameService", NACL_ABI_O_RDWR, | |
| 319 NaClDescRef(manifest_proxy->base.bound_and_cap[1])); | |
| 320 NaClXMutexUnlock(&nap->mu); | |
| 321 | |
| 322 NaClXMutexLock(&self->mu); | 293 NaClXMutexLock(&self->mu); |
| 323 self->reverse_channel_initialization_state = | 294 self->reverse_channel_initialization_state = |
| 324 NACL_REVERSE_CHANNEL_INITIALIZED; | 295 NACL_REVERSE_CHANNEL_INITIALIZED; |
| 325 NaClXCondVarBroadcast(&self->cv); | 296 NaClXCondVarBroadcast(&self->cv); |
| 326 NaClXMutexUnlock(&self->mu); | 297 NaClXMutexUnlock(&self->mu); |
| 327 | 298 |
| 328 cleanup_manifest_proxy: | |
| 329 NaClRefCountSafeUnref((struct NaClRefCount *) manifest_proxy); | |
| 330 cleanup_reverse_quota_interface: | 299 cleanup_reverse_quota_interface: |
| 331 NaClRefCountSafeUnref((struct NaClRefCount *) reverse_quota_interface); | 300 NaClRefCountSafeUnref((struct NaClRefCount *) reverse_quota_interface); |
| 332 cleanup_reverse_host_interface: | 301 cleanup_reverse_host_interface: |
| 333 NaClRefCountSafeUnref((struct NaClRefCount *) reverse_host_interface); | 302 NaClRefCountSafeUnref((struct NaClRefCount *) reverse_host_interface); |
| 334 done: | 303 done: |
| 335 NaClLog(4, "Leaving NaClSecureReverseClientCallback\n"); | 304 NaClLog(4, "Leaving NaClSecureReverseClientCallback\n"); |
| 336 } | 305 } |
| 337 | 306 |
| 338 static void NaClSecureServiceReverseSetupRpc( | 307 static void NaClSecureServiceReverseSetupRpc( |
| 339 struct NaClSrpcRpc *rpc, | 308 struct NaClSrpcRpc *rpc, |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 | 662 |
| 694 struct NaClSecureReverseClientVtbl const kNaClSecureReverseClientVtbl = { | 663 struct NaClSecureReverseClientVtbl const kNaClSecureReverseClientVtbl = { |
| 695 { | 664 { |
| 696 { | 665 { |
| 697 NaClSecureReverseClientDtor, | 666 NaClSecureReverseClientDtor, |
| 698 }, | 667 }, |
| 699 }, | 668 }, |
| 700 NaClSecureReverseClientInsertHandler, | 669 NaClSecureReverseClientInsertHandler, |
| 701 NaClSecureReverseClientRemoveHandler, | 670 NaClSecureReverseClientRemoveHandler, |
| 702 }; | 671 }; |
| OLD | NEW |