Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/nonsfi/nonsfi_main.h" | 5 #include "components/nacl/loader/nonsfi/nonsfi_main.h" |
| 6 | 6 |
| 7 #include "base/debug/leak_annotations.h" | 7 #include "base/debug/leak_annotations.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| 11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
| 12 #include "components/nacl/loader/nonsfi/elf_loader.h" | 12 #include "components/nacl/loader/nonsfi/elf_loader.h" |
| 13 #include "components/nacl/loader/nonsfi/irt_exception_handling.h" | |
| 13 #include "components/nacl/loader/nonsfi/irt_interfaces.h" | 14 #include "components/nacl/loader/nonsfi/irt_interfaces.h" |
| 14 #include "native_client/src/include/elf_auxv.h" | 15 #include "native_client/src/include/elf_auxv.h" |
| 15 #include "native_client/src/include/nacl_macros.h" | 16 #include "native_client/src/include/nacl_macros.h" |
| 16 #include "native_client/src/public/secure_service.h" | 17 #include "native_client/src/public/secure_service.h" |
| 17 #include "native_client/src/shared/srpc/nacl_srpc.h" | 18 #include "native_client/src/shared/srpc/nacl_srpc.h" |
| 18 #include "native_client/src/trusted/desc/nacl_desc_base.h" | 19 #include "native_client/src/trusted/desc/nacl_desc_base.h" |
| 19 #include "native_client/src/trusted/desc/nacl_desc_imc.h" | 20 #include "native_client/src/trusted/desc/nacl_desc_imc.h" |
| 20 #include "native_client/src/trusted/desc/nrd_all_modules.h" | 21 #include "native_client/src/trusted/desc/nrd_all_modules.h" |
| 21 #include "native_client/src/trusted/desc/nrd_xfer.h" | 22 #include "native_client/src/trusted/desc/nrd_xfer.h" |
| 22 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" | 23 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" |
| 24 #include "native_client/src/trusted/service_runtime/nacl_signal.h" | |
| 23 | 25 |
| 24 namespace nacl { | 26 namespace nacl { |
| 25 namespace nonsfi { | 27 namespace nonsfi { |
| 26 namespace { | 28 namespace { |
| 27 | 29 |
| 28 typedef void (*EntryPointType)(uintptr_t*); | 30 typedef void (*EntryPointType)(uintptr_t*); |
| 29 | 31 |
| 30 class PluginMainDelegate : public base::PlatformThread::Delegate { | 32 class PluginMainDelegate : public base::PlatformThread::Delegate { |
| 31 public: | 33 public: |
| 32 explicit PluginMainDelegate(EntryPointType entry_point) | 34 explicit PluginMainDelegate(EntryPointType entry_point) |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 LOG(ERROR) << "ServiceAccept: Failed to accept " << status; | 173 LOG(ERROR) << "ServiceAccept: Failed to accept " << status; |
| 172 return; | 174 return; |
| 173 } | 175 } |
| 174 | 176 |
| 175 NaClSrpcServerLoop(connected_desc, kNonSfiServiceHandlers, NULL); | 177 NaClSrpcServerLoop(connected_desc, kNonSfiServiceHandlers, NULL); |
| 176 } | 178 } |
| 177 | 179 |
| 178 } // namespace | 180 } // namespace |
| 179 | 181 |
| 180 void MainStart(NaClHandle imc_bootstrap_handle) { | 182 void MainStart(NaClHandle imc_bootstrap_handle) { |
| 183 // TODO(uekawa): Do I need to move it before InitializeBPFSandbox? | |
| 184 InitializeSignalHandler(); | |
|
Junichi Uekawa
2014/04/14 22:51:04
I'm not too sure when I need to initialize the han
hamaji
2014/04/15 15:23:35
As chatted, this won't succeed after seccomp-bpf f
Junichi Uekawa
2014/04/17 07:54:56
I've moved it around.
| |
| 185 | |
| 181 NaClSrpcModuleInit(); | 186 NaClSrpcModuleInit(); |
| 182 | 187 |
| 183 struct NaClDesc* secure_pair[2] = { NULL, NULL }; | 188 struct NaClDesc* secure_pair[2] = { NULL, NULL }; |
| 184 struct NaClDesc* pair[2] = { NULL, NULL }; | 189 struct NaClDesc* pair[2] = { NULL, NULL }; |
| 185 CreateSecureSocketPair(secure_pair, pair); | 190 CreateSecureSocketPair(secure_pair, pair); |
| 186 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> secure_port(secure_pair[0]); | 191 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> secure_port(secure_pair[0]); |
| 187 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> secure_address( | 192 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> secure_address( |
| 188 secure_pair[1]); | 193 secure_pair[1]); |
| 189 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> service_port(pair[0]); | 194 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> service_port(pair[0]); |
| 190 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> service_address(pair[1]); | 195 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> service_address(pair[1]); |
| 191 | 196 |
| 192 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> channel( | 197 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> channel( |
| 193 SetUpBootstrapChannel(imc_bootstrap_handle, | 198 SetUpBootstrapChannel(imc_bootstrap_handle, |
| 194 secure_address.get(), service_address.get())); | 199 secure_address.get(), service_address.get())); |
| 195 if (!channel) { | 200 if (!channel) { |
| 196 LOG(ERROR) << "MainStart: Failed to set up bootstrap channel."; | 201 LOG(ERROR) << "MainStart: Failed to set up bootstrap channel."; |
| 197 return; | 202 return; |
| 198 } | 203 } |
| 199 | 204 |
| 200 // Start the SRPC server loop. | 205 // Start the SRPC server loop. |
| 201 ServiceAccept(secure_port.get()); | 206 ServiceAccept(secure_port.get()); |
| 202 } | 207 } |
| 203 | 208 |
| 204 } // namespace nonsfi | 209 } // namespace nonsfi |
| 205 } // namespace nacl | 210 } // namespace nacl |
| OLD | NEW |