OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/zygote/zygote_main.h" | 5 #include "content/zygote/zygote_main.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <openssl/rand.h> | 9 #include <openssl/rand.h> |
10 #include <pthread.h> | 10 #include <pthread.h> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 void RunTwoClosures(const base::Closure* first, const base::Closure* second) { | 80 void RunTwoClosures(const base::Closure* first, const base::Closure* second) { |
81 first->Run(); | 81 first->Run(); |
82 second->Run(); | 82 second->Run(); |
83 } | 83 } |
84 | 84 |
85 } // namespace | 85 } // namespace |
86 | 86 |
87 // See http://code.google.com/p/chromium/wiki/LinuxZygote | 87 // See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_zygote
.md |
88 | 88 |
89 static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output, | 89 static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output, |
90 char* timezone_out, | 90 char* timezone_out, |
91 size_t timezone_out_len) { | 91 size_t timezone_out_len) { |
92 base::Pickle request; | 92 base::Pickle request; |
93 request.WriteInt(LinuxSandbox::METHOD_LOCALTIME); | 93 request.WriteInt(LinuxSandbox::METHOD_LOCALTIME); |
94 request.WriteString( | 94 request.WriteString( |
95 std::string(reinterpret_cast<char*>(&input), sizeof(input))); | 95 std::string(reinterpret_cast<char*>(&input), sizeof(input))); |
96 | 96 |
97 uint8_t reply_buf[512]; | 97 uint8_t reply_buf[512]; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // same binary for both the browser and the renderers, which means that our | 141 // same binary for both the browser and the renderers, which means that our |
142 // overrides will apply in the browser too. | 142 // overrides will apply in the browser too. |
143 // | 143 // |
144 // The global |g_am_zygote_or_renderer| is true iff we are in a zygote or | 144 // The global |g_am_zygote_or_renderer| is true iff we are in a zygote or |
145 // renderer process. It's set in ZygoteMain and inherited by the renderers when | 145 // renderer process. It's set in ZygoteMain and inherited by the renderers when |
146 // they fork. (This means that it'll be incorrect for global constructor | 146 // they fork. (This means that it'll be incorrect for global constructor |
147 // functions and before ZygoteMain is called - beware). | 147 // functions and before ZygoteMain is called - beware). |
148 // | 148 // |
149 // Our replacement functions can check this global and either proxy | 149 // Our replacement functions can check this global and either proxy |
150 // the call to the browser over the sandbox IPC | 150 // the call to the browser over the sandbox IPC |
151 // (http://code.google.com/p/chromium/wiki/LinuxSandboxIPC) or they can use | 151 // (https://chromium.googlesource.com/chromium/src/+/master/docs/linux_sandbox_i
pc.md) or they can use |
152 // dlsym with RTLD_NEXT to resolve the symbol, ignoring any symbols in the | 152 // dlsym with RTLD_NEXT to resolve the symbol, ignoring any symbols in the |
153 // current module. | 153 // current module. |
154 // | 154 // |
155 // Other avenues: | 155 // Other avenues: |
156 // | 156 // |
157 // Our first attempt involved some assembly to patch the GOT of the current | 157 // Our first attempt involved some assembly to patch the GOT of the current |
158 // module. This worked, but was platform specific and doesn't catch the case | 158 // module. This worked, but was platform specific and doesn't catch the case |
159 // where a library makes a call rather than current module. | 159 // where a library makes a call rather than current module. |
160 // | 160 // |
161 // We also considered patching the function in place, but this would again by | 161 // We also considered patching the function in place, but this would again by |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; | 609 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; |
610 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); | 610 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); |
611 | 611 |
612 Zygote zygote(sandbox_flags, std::move(fork_delegates), extra_children, | 612 Zygote zygote(sandbox_flags, std::move(fork_delegates), extra_children, |
613 extra_fds); | 613 extra_fds); |
614 // This function call can return multiple times, once per fork(). | 614 // This function call can return multiple times, once per fork(). |
615 return zygote.ProcessRequests(); | 615 return zygote.ProcessRequests(); |
616 } | 616 } |
617 | 617 |
618 } // namespace content | 618 } // namespace content |
OLD | NEW |