[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | a0f200ea | 2009-08-06 18:44:06 | [diff] [blame] | 5 | #include <dlfcn.h> |
[email protected] | a9c54a17 | 2009-11-07 06:09:38 | [diff] [blame] | 6 | #include <fcntl.h> |
[email protected] | 83a0cbe | 2009-11-04 04:22:47 | [diff] [blame] | 7 | #include <sys/epoll.h> |
[email protected] | 83a0cbe | 2009-11-04 04:22:47 | [diff] [blame] | 8 | #include <sys/prctl.h> |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 9 | #include <sys/signal.h> |
| 10 | #include <sys/socket.h> |
[email protected] | a9c54a17 | 2009-11-07 06:09:38 | [diff] [blame] | 11 | #include <sys/stat.h> |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 12 | #include <sys/types.h> |
[email protected] | 83a0cbe | 2009-11-04 04:22:47 | [diff] [blame] | 13 | #include <sys/wait.h> |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 14 | #include <unistd.h> |
| 15 | |
| 16 | #if defined(CHROMIUM_SELINUX) |
| 17 | #include <selinux/selinux.h> |
| 18 | #include <selinux/context.h> |
| 19 | #endif |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 20 | |
[email protected] | 789f70c7 | 2009-07-24 13:55:43 | [diff] [blame] | 21 | #include "base/basictypes.h" |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 22 | #include "base/command_line.h" |
| 23 | #include "base/eintr_wrapper.h" |
| 24 | #include "base/global_descriptors_posix.h" |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 25 | #include "base/hash_tables.h" |
| 26 | #include "base/linux_util.h" |
[email protected] | c9e45da0 | 2009-08-05 17:35:08 | [diff] [blame] | 27 | #include "base/path_service.h" |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 28 | #include "base/pickle.h" |
[email protected] | 4378a82 | 2009-07-08 01:15:14 | [diff] [blame] | 29 | #include "base/rand_util.h" |
[email protected] | 1831acf | 2009-10-05 16:38:41 | [diff] [blame] | 30 | #include "base/scoped_ptr.h" |
[email protected] | 80a086c5 | 2009-08-04 17:52:04 | [diff] [blame] | 31 | #include "base/sys_info.h" |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 32 | #include "base/unix_domain_socket_posix.h" |
[email protected] | 8015de3 | 2009-11-18 04:13:33 | [diff] [blame] | 33 | #include "build/build_config.h" |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 34 | |
| 35 | #include "chrome/browser/zygote_host_linux.h" |
| 36 | #include "chrome/common/chrome_descriptors.h" |
[email protected] | 4730db9 | 2009-07-22 00:40:48 | [diff] [blame] | 37 | #include "chrome/common/chrome_switches.h" |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 38 | #include "chrome/common/main_function_params.h" |
| 39 | #include "chrome/common/process_watcher.h" |
[email protected] | 73fa6399 | 2009-07-20 20:30:07 | [diff] [blame] | 40 | #include "chrome/common/sandbox_methods_linux.h" |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 41 | |
[email protected] | c9e45da0 | 2009-08-05 17:35:08 | [diff] [blame] | 42 | #include "media/base/media.h" |
| 43 | |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 44 | #include "skia/ext/SkFontHost_fontconfig_control.h" |
| 45 | |
[email protected] | e8c916a | 2009-11-04 17:52:47 | [diff] [blame] | 46 | #include "sandbox/linux/seccomp/sandbox.h" |
| 47 | |
[email protected] | 1831acf | 2009-10-05 16:38:41 | [diff] [blame] | 48 | #include "unicode/timezone.h" |
| 49 | |
[email protected] | 36ea6c6f | 2010-03-17 20:08:01 | [diff] [blame] | 50 | #if defined(ARCH_CPU_X86_FAMILY) && !defined(CHROMIUM_SELINUX) |
| 51 | // The seccomp sandbox is enabled on all ia32 and x86-64 processor as long as |
| 52 | // we aren't using SELinux. |
| 53 | #define SECCOMP_SANDBOX |
| 54 | #endif |
| 55 | |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 56 | // http://code.google.com/p/chromium/wiki/LinuxZygote |
| 57 | |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 58 | static const int kBrowserDescriptor = 3; |
[email protected] | 73fa6399 | 2009-07-20 20:30:07 | [diff] [blame] | 59 | static const int kMagicSandboxIPCDescriptor = 5; |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 60 | static const int kZygoteIdDescriptor = 7; |
| 61 | static bool g_suid_sandbox_active = false; |
[email protected] | 36ea6c6f | 2010-03-17 20:08:01 | [diff] [blame] | 62 | #if defined(SECCOMP_SANDBOX) |
[email protected] | 4f03cbc | 2009-11-19 00:50:48 | [diff] [blame] | 63 | // |g_proc_fd| is used only by the seccomp sandbox. |
[email protected] | a9c54a17 | 2009-11-07 06:09:38 | [diff] [blame] | 64 | static int g_proc_fd = -1; |
[email protected] | 4f03cbc | 2009-11-19 00:50:48 | [diff] [blame] | 65 | #endif |
[email protected] | 73fa6399 | 2009-07-20 20:30:07 | [diff] [blame] | 66 | |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 67 | // This is the object which implements the zygote. The ZygoteMain function, |
| 68 | // which is called from ChromeMain, at the the bottom and simple constructs one |
| 69 | // of these objects and runs it. |
| 70 | class Zygote { |
| 71 | public: |
| 72 | bool ProcessRequests() { |
| 73 | // A SOCK_SEQPACKET socket is installed in fd 3. We get commands from the |
| 74 | // browser on it. |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 75 | // A SOCK_DGRAM is installed in fd 5. This is the sandbox IPC channel. |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 76 | // See http://code.google.com/p/chromium/wiki/LinuxSandboxIPC |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 77 | |
| 78 | // We need to accept SIGCHLD, even though our handler is a no-op because |
| 79 | // otherwise we cannot wait on children. (According to POSIX 2001.) |
| 80 | struct sigaction action; |
| 81 | memset(&action, 0, sizeof(action)); |
| 82 | action.sa_handler = SIGCHLDHandler; |
| 83 | CHECK(sigaction(SIGCHLD, &action, NULL) == 0); |
| 84 | |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 85 | if (g_suid_sandbox_active) { |
| 86 | // Let the ZygoteHost know we are ready to go. |
| 87 | // The receiving code is in chrome/browser/zygote_host_linux.cc. |
| 88 | std::vector<int> empty; |
| 89 | bool r = base::SendMsg(kBrowserDescriptor, kZygoteMagic, |
| 90 | sizeof(kZygoteMagic), empty); |
| 91 | CHECK(r) << "Sending zygote magic failed"; |
| 92 | } |
| 93 | |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 94 | for (;;) { |
[email protected] | c548be2 | 2010-03-08 12:55:57 | [diff] [blame] | 95 | // This function call can return multiple times, once per fork(). |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 96 | if (HandleRequestFromBrowser(kBrowserDescriptor)) |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 97 | return true; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | private: |
| 102 | // See comment below, where sigaction is called. |
| 103 | static void SIGCHLDHandler(int signal) { } |
| 104 | |
| 105 | // --------------------------------------------------------------------------- |
| 106 | // Requests from the browser... |
| 107 | |
| 108 | // Read and process a request from the browser. Returns true if we are in a |
| 109 | // new process and thus need to unwind back into ChromeMain. |
| 110 | bool HandleRequestFromBrowser(int fd) { |
| 111 | std::vector<int> fds; |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 112 | static const unsigned kMaxMessageLength = 1024; |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 113 | char buf[kMaxMessageLength]; |
| 114 | const ssize_t len = base::RecvMsg(fd, buf, sizeof(buf), &fds); |
| 115 | if (len == -1) { |
| 116 | LOG(WARNING) << "Error reading message from browser: " << errno; |
| 117 | return false; |
| 118 | } |
| 119 | |
| 120 | if (len == 0) { |
| 121 | // EOF from the browser. We should die. |
| 122 | _exit(0); |
| 123 | return false; |
| 124 | } |
| 125 | |
| 126 | Pickle pickle(buf, len); |
| 127 | void* iter = NULL; |
| 128 | |
| 129 | int kind; |
[email protected] | 57113ea | 2009-06-18 02:23:16 | [diff] [blame] | 130 | if (pickle.ReadInt(&iter, &kind)) { |
| 131 | switch (kind) { |
| 132 | case ZygoteHost::kCmdFork: |
[email protected] | c548be2 | 2010-03-08 12:55:57 | [diff] [blame] | 133 | // This function call can return multiple times, once per fork(). |
[email protected] | 57113ea | 2009-06-18 02:23:16 | [diff] [blame] | 134 | return HandleForkRequest(fd, pickle, iter, fds); |
| 135 | case ZygoteHost::kCmdReap: |
| 136 | if (!fds.empty()) |
| 137 | break; |
[email protected] | c548be2 | 2010-03-08 12:55:57 | [diff] [blame] | 138 | HandleReapRequest(fd, pickle, iter); |
| 139 | return false; |
[email protected] | 57113ea | 2009-06-18 02:23:16 | [diff] [blame] | 140 | case ZygoteHost::kCmdDidProcessCrash: |
| 141 | if (!fds.empty()) |
| 142 | break; |
[email protected] | c548be2 | 2010-03-08 12:55:57 | [diff] [blame] | 143 | HandleDidProcessCrash(fd, pickle, iter); |
| 144 | return false; |
[email protected] | 57113ea | 2009-06-18 02:23:16 | [diff] [blame] | 145 | default: |
| 146 | NOTREACHED(); |
| 147 | break; |
| 148 | } |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 149 | } |
| 150 | |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 151 | LOG(WARNING) << "Error parsing message from browser"; |
| 152 | for (std::vector<int>::const_iterator |
| 153 | i = fds.begin(); i != fds.end(); ++i) |
| 154 | close(*i); |
| 155 | return false; |
| 156 | } |
| 157 | |
[email protected] | c548be2 | 2010-03-08 12:55:57 | [diff] [blame] | 158 | void HandleReapRequest(int fd, const Pickle& pickle, void* iter) { |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 159 | base::ProcessId child; |
| 160 | base::ProcessId actual_child; |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 161 | |
| 162 | if (!pickle.ReadInt(&iter, &child)) { |
| 163 | LOG(WARNING) << "Error parsing reap request from browser"; |
[email protected] | c548be2 | 2010-03-08 12:55:57 | [diff] [blame] | 164 | return; |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 165 | } |
| 166 | |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 167 | if (g_suid_sandbox_active) { |
| 168 | actual_child = real_pids_to_sandbox_pids[child]; |
| 169 | if (!actual_child) |
[email protected] | c548be2 | 2010-03-08 12:55:57 | [diff] [blame] | 170 | return; |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 171 | real_pids_to_sandbox_pids.erase(child); |
| 172 | } else { |
| 173 | actual_child = child; |
| 174 | } |
| 175 | |
| 176 | ProcessWatcher::EnsureProcessTerminated(actual_child); |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 177 | } |
| 178 | |
[email protected] | c548be2 | 2010-03-08 12:55:57 | [diff] [blame] | 179 | void HandleDidProcessCrash(int fd, const Pickle& pickle, void* iter) { |
[email protected] | 57113ea | 2009-06-18 02:23:16 | [diff] [blame] | 180 | base::ProcessHandle child; |
| 181 | |
| 182 | if (!pickle.ReadInt(&iter, &child)) { |
| 183 | LOG(WARNING) << "Error parsing DidProcessCrash request from browser"; |
[email protected] | c548be2 | 2010-03-08 12:55:57 | [diff] [blame] | 184 | return; |
[email protected] | 57113ea | 2009-06-18 02:23:16 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | bool child_exited; |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 188 | bool did_crash; |
| 189 | if (g_suid_sandbox_active) |
| 190 | child = real_pids_to_sandbox_pids[child]; |
| 191 | if (child) |
| 192 | did_crash = base::DidProcessCrash(&child_exited, child); |
| 193 | else |
| 194 | did_crash = child_exited = false; |
[email protected] | 57113ea | 2009-06-18 02:23:16 | [diff] [blame] | 195 | |
| 196 | Pickle write_pickle; |
| 197 | write_pickle.WriteBool(did_crash); |
| 198 | write_pickle.WriteBool(child_exited); |
| 199 | HANDLE_EINTR(write(fd, write_pickle.data(), write_pickle.size())); |
[email protected] | 57113ea | 2009-06-18 02:23:16 | [diff] [blame] | 200 | } |
| 201 | |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 202 | // Handle a 'fork' request from the browser: this means that the browser |
| 203 | // wishes to start a new renderer. |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 204 | bool HandleForkRequest(int fd, const Pickle& pickle, void* iter, |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 205 | std::vector<int>& fds) { |
| 206 | std::vector<std::string> args; |
| 207 | int argc, numfds; |
| 208 | base::GlobalDescriptors::Mapping mapping; |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 209 | base::ProcessId child; |
| 210 | uint64_t dummy_inode = 0; |
| 211 | int dummy_fd = -1; |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 212 | |
| 213 | if (!pickle.ReadInt(&iter, &argc)) |
| 214 | goto error; |
| 215 | |
| 216 | for (int i = 0; i < argc; ++i) { |
| 217 | std::string arg; |
| 218 | if (!pickle.ReadString(&iter, &arg)) |
| 219 | goto error; |
| 220 | args.push_back(arg); |
| 221 | } |
| 222 | |
| 223 | if (!pickle.ReadInt(&iter, &numfds)) |
| 224 | goto error; |
| 225 | if (numfds != static_cast<int>(fds.size())) |
| 226 | goto error; |
| 227 | |
| 228 | for (int i = 0; i < numfds; ++i) { |
| 229 | base::GlobalDescriptors::Key key; |
| 230 | if (!pickle.ReadUInt32(&iter, &key)) |
| 231 | goto error; |
| 232 | mapping.push_back(std::make_pair(key, fds[i])); |
| 233 | } |
| 234 | |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 235 | mapping.push_back(std::make_pair( |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 236 | static_cast<uint32_t>(kSandboxIPCChannel), kMagicSandboxIPCDescriptor)); |
| 237 | |
| 238 | if (g_suid_sandbox_active) { |
| 239 | dummy_fd = socket(PF_UNIX, SOCK_DGRAM, 0); |
| 240 | if (dummy_fd < 0) |
| 241 | goto error; |
| 242 | |
| 243 | if (!base::FileDescriptorGetInode(&dummy_inode, dummy_fd)) |
| 244 | goto error; |
| 245 | } |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 246 | |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 247 | child = fork(); |
| 248 | |
| 249 | if (!child) { |
[email protected] | 36ea6c6f | 2010-03-17 20:08:01 | [diff] [blame] | 250 | #if defined(SECCOMP_SANDBOX) |
[email protected] | a9c54a17 | 2009-11-07 06:09:38 | [diff] [blame] | 251 | // Try to open /proc/self/maps as the seccomp sandbox needs access to it |
| 252 | if (g_proc_fd >= 0) { |
| 253 | int proc_self_maps = openat(g_proc_fd, "self/maps", O_RDONLY); |
| 254 | if (proc_self_maps >= 0) { |
| 255 | SeccompSandboxSetProcSelfMaps(proc_self_maps); |
| 256 | } |
| 257 | close(g_proc_fd); |
| 258 | g_proc_fd = -1; |
| 259 | } |
[email protected] | 8015de3 | 2009-11-18 04:13:33 | [diff] [blame] | 260 | #endif |
[email protected] | a9c54a17 | 2009-11-07 06:09:38 | [diff] [blame] | 261 | |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 262 | close(kBrowserDescriptor); // our socket from the browser |
[email protected] | cbcf9cc3 | 2010-02-17 04:05:59 | [diff] [blame] | 263 | if (g_suid_sandbox_active) |
| 264 | close(kZygoteIdDescriptor); // another socket from the browser |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 265 | Singleton<base::GlobalDescriptors>()->Reset(mapping); |
[email protected] | 0189bbd | 2009-10-12 22:50:39 | [diff] [blame] | 266 | |
| 267 | // Reset the process-wide command line to our new command line. |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 268 | CommandLine::Reset(); |
[email protected] | 0189bbd | 2009-10-12 22:50:39 | [diff] [blame] | 269 | CommandLine::Init(0, NULL); |
| 270 | CommandLine::ForCurrentProcess()->InitFromArgv(args); |
[email protected] | 7f113f3 | 2009-09-10 18:02:17 | [diff] [blame] | 271 | CommandLine::SetProcTitle(); |
[email protected] | c548be2 | 2010-03-08 12:55:57 | [diff] [blame] | 272 | // The fork() request is handled further up the call stack. |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 273 | return true; |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 274 | } else if (child < 0) { |
| 275 | LOG(ERROR) << "Zygote could not fork"; |
| 276 | goto error; |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 277 | } |
| 278 | |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 279 | { |
| 280 | base::ProcessId proc_id; |
| 281 | if (g_suid_sandbox_active) { |
| 282 | close(dummy_fd); |
| 283 | dummy_fd = -1; |
| 284 | uint8_t reply_buf[512]; |
| 285 | Pickle request; |
| 286 | request.WriteInt(LinuxSandbox::METHOD_GET_CHILD_WITH_INODE); |
| 287 | request.WriteUInt64(dummy_inode); |
[email protected] | 83a0cbe | 2009-11-04 04:22:47 | [diff] [blame] | 288 | |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 289 | const ssize_t r = base::SendRecvMsg(kMagicSandboxIPCDescriptor, |
| 290 | reply_buf, sizeof(reply_buf), |
| 291 | NULL, request); |
| 292 | if (r == -1) |
| 293 | goto error; |
| 294 | |
| 295 | Pickle reply(reinterpret_cast<char*>(reply_buf), r); |
| 296 | void* iter2 = NULL; |
| 297 | if (!reply.ReadInt(&iter2, &proc_id)) |
| 298 | goto error; |
| 299 | real_pids_to_sandbox_pids[proc_id] = child; |
| 300 | } else { |
| 301 | proc_id = child; |
| 302 | } |
| 303 | |
| 304 | for (std::vector<int>::const_iterator |
| 305 | i = fds.begin(); i != fds.end(); ++i) |
| 306 | close(*i); |
| 307 | |
| 308 | HANDLE_EINTR(write(fd, &proc_id, sizeof(proc_id))); |
| 309 | return false; |
| 310 | } |
[email protected] | 83a0cbe | 2009-11-04 04:22:47 | [diff] [blame] | 311 | |
| 312 | error: |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 313 | LOG(ERROR) << "Error parsing fork request from browser"; |
[email protected] | 83a0cbe | 2009-11-04 04:22:47 | [diff] [blame] | 314 | for (std::vector<int>::const_iterator |
| 315 | i = fds.begin(); i != fds.end(); ++i) |
| 316 | close(*i); |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 317 | if (dummy_fd >= 0) |
| 318 | close(dummy_fd); |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 319 | return false; |
| 320 | } |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 321 | |
| 322 | // In the SUID sandbox, we try to use a new PID namespace. Thus the PIDs |
| 323 | // fork() returns are not the real PIDs, so we need to map the Real PIDS |
| 324 | // into the sandbox PID namespace. |
| 325 | typedef base::hash_map<base::ProcessHandle, base::ProcessHandle> ProcessMap; |
| 326 | ProcessMap real_pids_to_sandbox_pids; |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 327 | }; |
| 328 | |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 329 | // With SELinux we can carve out a precise sandbox, so we don't have to play |
| 330 | // with intercepting libc calls. |
| 331 | #if !defined(CHROMIUM_SELINUX) |
| 332 | |
[email protected] | a0f200ea | 2009-08-06 18:44:06 | [diff] [blame] | 333 | static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output, |
| 334 | char* timezone_out, |
| 335 | size_t timezone_out_len) { |
[email protected] | 73fa6399 | 2009-07-20 20:30:07 | [diff] [blame] | 336 | Pickle request; |
| 337 | request.WriteInt(LinuxSandbox::METHOD_LOCALTIME); |
| 338 | request.WriteString( |
| 339 | std::string(reinterpret_cast<char*>(&input), sizeof(input))); |
| 340 | |
| 341 | uint8_t reply_buf[512]; |
| 342 | const ssize_t r = base::SendRecvMsg( |
| 343 | kMagicSandboxIPCDescriptor, reply_buf, sizeof(reply_buf), NULL, request); |
| 344 | if (r == -1) { |
| 345 | memset(output, 0, sizeof(struct tm)); |
| 346 | return; |
| 347 | } |
| 348 | |
| 349 | Pickle reply(reinterpret_cast<char*>(reply_buf), r); |
| 350 | void* iter = NULL; |
[email protected] | 9debcda5 | 2009-07-22 20:06:51 | [diff] [blame] | 351 | std::string result, timezone; |
[email protected] | 73fa6399 | 2009-07-20 20:30:07 | [diff] [blame] | 352 | if (!reply.ReadString(&iter, &result) || |
[email protected] | 9debcda5 | 2009-07-22 20:06:51 | [diff] [blame] | 353 | !reply.ReadString(&iter, &timezone) || |
[email protected] | 73fa6399 | 2009-07-20 20:30:07 | [diff] [blame] | 354 | result.size() != sizeof(struct tm)) { |
| 355 | memset(output, 0, sizeof(struct tm)); |
| 356 | return; |
| 357 | } |
| 358 | |
| 359 | memcpy(output, result.data(), sizeof(struct tm)); |
[email protected] | 9debcda5 | 2009-07-22 20:06:51 | [diff] [blame] | 360 | if (timezone_out_len) { |
| 361 | const size_t copy_len = std::min(timezone_out_len - 1, timezone.size()); |
| 362 | memcpy(timezone_out, timezone.data(), copy_len); |
| 363 | timezone_out[copy_len] = 0; |
| 364 | output->tm_zone = timezone_out; |
| 365 | } else { |
| 366 | output->tm_zone = NULL; |
| 367 | } |
[email protected] | 73fa6399 | 2009-07-20 20:30:07 | [diff] [blame] | 368 | } |
| 369 | |
[email protected] | a0f200ea | 2009-08-06 18:44:06 | [diff] [blame] | 370 | static bool g_am_zygote_or_renderer = false; |
| 371 | |
| 372 | // Sandbox interception of libc calls. |
| 373 | // |
| 374 | // Because we are running in a sandbox certain libc calls will fail (localtime |
| 375 | // being the motivating example - it needs to read /etc/localtime). We need to |
| 376 | // intercept these calls and proxy them to the browser. However, these calls |
| 377 | // may come from us or from our libraries. In some cases we can't just change |
| 378 | // our code. |
| 379 | // |
| 380 | // It's for these cases that we have the following setup: |
| 381 | // |
| 382 | // We define global functions for those functions which we wish to override. |
| 383 | // Since we will be first in the dynamic resolution order, the dynamic linker |
| 384 | // will point callers to our versions of these functions. However, we have the |
| 385 | // same binary for both the browser and the renderers, which means that our |
| 386 | // overrides will apply in the browser too. |
| 387 | // |
| 388 | // The global |g_am_zygote_or_renderer| is true iff we are in a zygote or |
| 389 | // renderer process. It's set in ZygoteMain and inherited by the renderers when |
| 390 | // they fork. (This means that it'll be incorrect for global constructor |
| 391 | // functions and before ZygoteMain is called - beware). |
| 392 | // |
| 393 | // Our replacement functions can check this global and either proxy |
| 394 | // the call to the browser over the sandbox IPC |
| 395 | // (http://code.google.com/p/chromium/wiki/LinuxSandboxIPC) or they can use |
| 396 | // dlsym with RTLD_NEXT to resolve the symbol, ignoring any symbols in the |
| 397 | // current module. |
| 398 | // |
| 399 | // Other avenues: |
| 400 | // |
| 401 | // Our first attempt involved some assembly to patch the GOT of the current |
| 402 | // module. This worked, but was platform specific and doesn't catch the case |
| 403 | // where a library makes a call rather than current module. |
| 404 | // |
| 405 | // We also considered patching the function in place, but this would again by |
| 406 | // platform specific and the above technique seems to work well enough. |
| 407 | |
[email protected] | a5d7bb8 | 2009-09-08 22:30:58 | [diff] [blame] | 408 | static void WarnOnceAboutBrokenDlsym(); |
| 409 | |
[email protected] | 73fa6399 | 2009-07-20 20:30:07 | [diff] [blame] | 410 | struct tm* localtime(const time_t* timep) { |
[email protected] | a0f200ea | 2009-08-06 18:44:06 | [diff] [blame] | 411 | if (g_am_zygote_or_renderer) { |
| 412 | static struct tm time_struct; |
| 413 | static char timezone_string[64]; |
| 414 | ProxyLocaltimeCallToBrowser(*timep, &time_struct, timezone_string, |
| 415 | sizeof(timezone_string)); |
| 416 | return &time_struct; |
| 417 | } else { |
| 418 | typedef struct tm* (*LocaltimeFunction)(const time_t* timep); |
| 419 | static LocaltimeFunction libc_localtime; |
[email protected] | a5d7bb8 | 2009-09-08 22:30:58 | [diff] [blame] | 420 | static bool have_libc_localtime = false; |
| 421 | if (!have_libc_localtime) { |
[email protected] | a0f200ea | 2009-08-06 18:44:06 | [diff] [blame] | 422 | libc_localtime = (LocaltimeFunction) dlsym(RTLD_NEXT, "localtime"); |
[email protected] | a5d7bb8 | 2009-09-08 22:30:58 | [diff] [blame] | 423 | have_libc_localtime = true; |
| 424 | } |
| 425 | |
| 426 | if (!libc_localtime) { |
| 427 | // http://code.google.com/p/chromium/issues/detail?id=16800 |
| 428 | // |
| 429 | // Nvidia's libGL.so overrides dlsym for an unknown reason and replaces |
| 430 | // it with a version which doesn't work. In this case we'll get a NULL |
| 431 | // result. There's not a lot we can do at this point, so we just bodge it! |
| 432 | WarnOnceAboutBrokenDlsym(); |
| 433 | |
| 434 | return gmtime(timep); |
| 435 | } |
[email protected] | a0f200ea | 2009-08-06 18:44:06 | [diff] [blame] | 436 | |
| 437 | return libc_localtime(timep); |
| 438 | } |
[email protected] | 73fa6399 | 2009-07-20 20:30:07 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | struct tm* localtime_r(const time_t* timep, struct tm* result) { |
[email protected] | a0f200ea | 2009-08-06 18:44:06 | [diff] [blame] | 442 | if (g_am_zygote_or_renderer) { |
| 443 | ProxyLocaltimeCallToBrowser(*timep, result, NULL, 0); |
| 444 | return result; |
| 445 | } else { |
| 446 | typedef struct tm* (*LocaltimeRFunction)(const time_t* timep, |
| 447 | struct tm* result); |
| 448 | static LocaltimeRFunction libc_localtime_r; |
[email protected] | a5d7bb8 | 2009-09-08 22:30:58 | [diff] [blame] | 449 | static bool have_libc_localtime_r = false; |
| 450 | if (!have_libc_localtime_r) { |
[email protected] | a0f200ea | 2009-08-06 18:44:06 | [diff] [blame] | 451 | libc_localtime_r = (LocaltimeRFunction) dlsym(RTLD_NEXT, "localtime_r"); |
[email protected] | a5d7bb8 | 2009-09-08 22:30:58 | [diff] [blame] | 452 | have_libc_localtime_r = true; |
| 453 | } |
| 454 | |
| 455 | if (!libc_localtime_r) { |
| 456 | // See |localtime|, above. |
| 457 | WarnOnceAboutBrokenDlsym(); |
| 458 | |
| 459 | return gmtime_r(timep, result); |
| 460 | } |
[email protected] | a0f200ea | 2009-08-06 18:44:06 | [diff] [blame] | 461 | |
| 462 | return libc_localtime_r(timep, result); |
| 463 | } |
[email protected] | 73fa6399 | 2009-07-20 20:30:07 | [diff] [blame] | 464 | } |
| 465 | |
[email protected] | a5d7bb8 | 2009-09-08 22:30:58 | [diff] [blame] | 466 | // See the comments at the callsite in |localtime| about this function. |
| 467 | static void WarnOnceAboutBrokenDlsym() { |
| 468 | static bool have_shown_warning = false; |
| 469 | if (!have_shown_warning) { |
| 470 | LOG(ERROR) << "Your system is broken: dlsym doesn't work! This has been " |
| 471 | "reported to be caused by Nvidia's libGL. You should expect " |
| 472 | "time related functions to misbehave. " |
| 473 | "http://code.google.com/p/chromium/issues/detail?id=16800"; |
| 474 | have_shown_warning = true; |
| 475 | } |
| 476 | } |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 477 | #endif // !CHROMIUM_SELINUX |
[email protected] | a5d7bb8 | 2009-09-08 22:30:58 | [diff] [blame] | 478 | |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 479 | // This function triggers the static and lazy construction of objects that need |
| 480 | // to be created before imposing the sandbox. |
| 481 | static void PreSandboxInit() { |
[email protected] | b841941 | 2010-03-29 20:18:29 | [diff] [blame^] | 482 | base::RandUint64(); |
[email protected] | 4378a82 | 2009-07-08 01:15:14 | [diff] [blame] | 483 | |
[email protected] | b841941 | 2010-03-29 20:18:29 | [diff] [blame^] | 484 | base::SysInfo::MaxSharedMemorySize(); |
[email protected] | 80a086c5 | 2009-08-04 17:52:04 | [diff] [blame] | 485 | |
[email protected] | b841941 | 2010-03-29 20:18:29 | [diff] [blame^] | 486 | // To make wcstombs/mbstowcs work in a renderer, setlocale() has to be |
| 487 | // called before the sandbox is triggered. It's possible to avoid calling |
| 488 | // setlocale() by pulling out the conversion between FilePath and |
| 489 | // WebCore String out of the renderer and using string16 in place of |
| 490 | // FilePath for IPC. |
| 491 | const char* locale = setlocale(LC_ALL, ""); |
| 492 | LOG_IF(WARNING, locale == NULL) << "setlocale failed."; |
[email protected] | e6acd67 | 2009-07-24 21:51:33 | [diff] [blame] | 493 | |
[email protected] | b841941 | 2010-03-29 20:18:29 | [diff] [blame^] | 494 | // ICU DateFormat class (used in base/time_format.cc) needs to get the |
| 495 | // Olson timezone ID by accessing the zoneinfo files on disk. After |
| 496 | // TimeZone::createDefault is called once here, the timezone ID is |
| 497 | // cached and there's no more need to access the file system. |
| 498 | scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); |
[email protected] | 1831acf | 2009-10-05 16:38:41 | [diff] [blame] | 499 | |
[email protected] | b841941 | 2010-03-29 20:18:29 | [diff] [blame^] | 500 | FilePath module_path; |
| 501 | if (PathService::Get(base::DIR_MODULE, &module_path)) |
| 502 | media::InitializeMediaLibrary(module_path); |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | #if !defined(CHROMIUM_SELINUX) |
| 506 | static bool EnterSandbox() { |
[email protected] | b841941 | 2010-03-29 20:18:29 | [diff] [blame^] | 507 | // The SUID sandbox sets this environment variable to a file descriptor |
| 508 | // over which we can signal that we have completed our startup and can be |
| 509 | // chrooted. |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 510 | const char* const sandbox_fd_string = getenv("SBX_D"); |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 511 | |
[email protected] | b841941 | 2010-03-29 20:18:29 | [diff] [blame^] | 512 | if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 513 | switches::kEnableSeccompSandbox)) { |
| 514 | PreSandboxInit(); |
| 515 | SkiaFontConfigUseIPCImplementation(kMagicSandboxIPCDescriptor); |
| 516 | } else if (sandbox_fd_string) { // Use the SUID sandbox. |
[email protected] | 8ecd3aad | 2009-11-04 08:32:22 | [diff] [blame] | 517 | g_suid_sandbox_active = true; |
| 518 | |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 519 | char* endptr; |
| 520 | const long fd_long = strtol(sandbox_fd_string, &endptr, 10); |
| 521 | if (!*sandbox_fd_string || *endptr || fd_long < 0 || fd_long > INT_MAX) |
| 522 | return false; |
| 523 | const int fd = fd_long; |
| 524 | |
| 525 | PreSandboxInit(); |
[email protected] | c9e45da0 | 2009-08-05 17:35:08 | [diff] [blame] | 526 | |
[email protected] | eaebefaf | 2010-02-23 22:58:18 | [diff] [blame] | 527 | static const char kMsgChrootMe = 'C'; |
| 528 | static const char kMsgChrootSuccessful = 'O'; |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 529 | |
[email protected] | eaebefaf | 2010-02-23 22:58:18 | [diff] [blame] | 530 | if (HANDLE_EINTR(write(fd, &kMsgChrootMe, 1)) != 1) { |
[email protected] | 0e161112 | 2009-07-10 18:17:32 | [diff] [blame] | 531 | LOG(ERROR) << "Failed to write to chroot pipe: " << errno; |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 532 | return false; |
[email protected] | 0e161112 | 2009-07-10 18:17:32 | [diff] [blame] | 533 | } |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 534 | |
[email protected] | 87ed695 | 2009-07-16 02:52:15 | [diff] [blame] | 535 | // We need to reap the chroot helper process in any event: |
| 536 | wait(NULL); |
| 537 | |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 538 | char reply; |
[email protected] | 87f8ce6 | 2009-07-10 19:14:31 | [diff] [blame] | 539 | if (HANDLE_EINTR(read(fd, &reply, 1)) != 1) { |
[email protected] | 0e161112 | 2009-07-10 18:17:32 | [diff] [blame] | 540 | LOG(ERROR) << "Failed to read from chroot pipe: " << errno; |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 541 | return false; |
[email protected] | 0e161112 | 2009-07-10 18:17:32 | [diff] [blame] | 542 | } |
[email protected] | 87f8ce6 | 2009-07-10 19:14:31 | [diff] [blame] | 543 | |
[email protected] | eaebefaf | 2010-02-23 22:58:18 | [diff] [blame] | 544 | if (reply != kMsgChrootSuccessful) { |
[email protected] | 0e161112 | 2009-07-10 18:17:32 | [diff] [blame] | 545 | LOG(ERROR) << "Error code reply from chroot helper"; |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 546 | return false; |
[email protected] | 0e161112 | 2009-07-10 18:17:32 | [diff] [blame] | 547 | } |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 548 | |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 549 | SkiaFontConfigUseIPCImplementation(kMagicSandboxIPCDescriptor); |
| 550 | |
[email protected] | 415493be | 2009-07-10 17:50:24 | [diff] [blame] | 551 | // Previously, we required that the binary be non-readable. This causes the |
| 552 | // kernel to mark the process as non-dumpable at startup. The thinking was |
| 553 | // that, although we were putting the renderers into a PID namespace (with |
| 554 | // the SUID sandbox), they would nonetheless be in the /same/ PID |
| 555 | // namespace. So they could ptrace each other unless they were non-dumpable. |
| 556 | // |
| 557 | // If the binary was readable, then there would be a window between process |
| 558 | // startup and the point where we set the non-dumpable flag in which a |
| 559 | // compromised renderer could ptrace attach. |
| 560 | // |
| 561 | // However, now that we have a zygote model, only the (trusted) zygote |
| 562 | // exists at this point and we can set the non-dumpable flag which is |
| 563 | // inherited by all our renderer children. |
[email protected] | 4730db9 | 2009-07-22 00:40:48 | [diff] [blame] | 564 | // |
| 565 | // Note: a non-dumpable process can't be debugged. To debug sandbox-related |
| 566 | // issues, one can specify --allow-sandbox-debugging to let the process be |
| 567 | // dumpable. |
| 568 | const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 569 | if (!command_line.HasSwitch(switches::kAllowSandboxDebugging)) { |
| 570 | prctl(PR_SET_DUMPABLE, 0, 0, 0, 0); |
| 571 | if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0)) { |
| 572 | LOG(ERROR) << "Failed to set non-dumpable flag"; |
| 573 | return false; |
| 574 | } |
[email protected] | 0e161112 | 2009-07-10 18:17:32 | [diff] [blame] | 575 | } |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 576 | } else { |
| 577 | SkiaFontConfigUseDirectImplementation(); |
| 578 | } |
| 579 | |
| 580 | return true; |
| 581 | } |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 582 | #else // CHROMIUM_SELINUX |
| 583 | |
| 584 | static bool EnterSandbox() { |
| 585 | PreSandboxInit(); |
| 586 | SkiaFontConfigUseIPCImplementation(kMagicSandboxIPCDescriptor); |
| 587 | |
| 588 | security_context_t security_context; |
| 589 | if (getcon(&security_context)) { |
| 590 | LOG(ERROR) << "Cannot get SELinux context"; |
| 591 | return false; |
| 592 | } |
| 593 | |
| 594 | context_t context = context_new(security_context); |
[email protected] | 36ea6c6f | 2010-03-17 20:08:01 | [diff] [blame] | 595 | context_type_set(context, "chromium_zygote_t"); |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 596 | const int r = setcon(context_str(context)); |
| 597 | context_free(context); |
| 598 | freecon(security_context); |
| 599 | |
| 600 | if (r) { |
[email protected] | 36ea6c6f | 2010-03-17 20:08:01 | [diff] [blame] | 601 | LOG(ERROR) << "dynamic transition to type 'chromium_zygote_t' failed. " |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 602 | "(this binary has been built with SELinux support, but maybe " |
[email protected] | 36ea6c6f | 2010-03-17 20:08:01 | [diff] [blame] | 603 | "the policies haven't been loaded into the kernel?)"; |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 604 | return false; |
| 605 | } |
| 606 | |
| 607 | return true; |
| 608 | } |
| 609 | |
| 610 | #endif // CHROMIUM_SELINUX |
[email protected] | abe3ad9 | 2009-06-15 18:15:08 | [diff] [blame] | 611 | |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 612 | bool ZygoteMain(const MainFunctionParams& params) { |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 613 | #if !defined(CHROMIUM_SELINUX) |
[email protected] | a0f200ea | 2009-08-06 18:44:06 | [diff] [blame] | 614 | g_am_zygote_or_renderer = true; |
[email protected] | ad6d2c4 | 2009-09-15 20:13:38 | [diff] [blame] | 615 | #endif |
[email protected] | a0f200ea | 2009-08-06 18:44:06 | [diff] [blame] | 616 | |
[email protected] | 36ea6c6f | 2010-03-17 20:08:01 | [diff] [blame] | 617 | #if defined(SECCOMP_SANDBOX) |
[email protected] | a9c54a17 | 2009-11-07 06:09:38 | [diff] [blame] | 618 | // The seccomp sandbox needs access to files in /proc, which might be denied |
| 619 | // after one of the other sandboxes have been started. So, obtain a suitable |
| 620 | // file handle in advance. |
[email protected] | 1b5d28f | 2010-02-18 15:53:36 | [diff] [blame] | 621 | if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 622 | switches::kEnableSeccompSandbox)) { |
[email protected] | a9c54a17 | 2009-11-07 06:09:38 | [diff] [blame] | 623 | g_proc_fd = open("/proc", O_DIRECTORY | O_RDONLY); |
| 624 | if (g_proc_fd < 0) { |
| 625 | LOG(ERROR) << "WARNING! Cannot access \"/proc\". Disabling seccomp " |
| 626 | "sandboxing."; |
| 627 | } |
| 628 | } |
[email protected] | 36ea6c6f | 2010-03-17 20:08:01 | [diff] [blame] | 629 | #endif // SECCOMP_SANDBOX |
[email protected] | a9c54a17 | 2009-11-07 06:09:38 | [diff] [blame] | 630 | |
| 631 | // Turn on the SELinux or SUID sandbox |
| 632 | if (!EnterSandbox()) { |
| 633 | LOG(FATAL) << "Failed to enter sandbox. Fail safe abort. (errno: " |
| 634 | << errno << ")"; |
| 635 | return false; |
| 636 | } |
| 637 | |
[email protected] | 36ea6c6f | 2010-03-17 20:08:01 | [diff] [blame] | 638 | #if defined(SECCOMP_SANDBOX) |
[email protected] | a9c54a17 | 2009-11-07 06:09:38 | [diff] [blame] | 639 | // The seccomp sandbox will be turned on when the renderers start. But we can |
| 640 | // already check if sufficient support is available so that we only need to |
| 641 | // print one error message for the entire browser session. |
| 642 | if (g_proc_fd >= 0 && |
[email protected] | 1b5d28f | 2010-02-18 15:53:36 | [diff] [blame] | 643 | CommandLine::ForCurrentProcess()->HasSwitch( |
| 644 | switches::kEnableSeccompSandbox)) { |
[email protected] | a9c54a17 | 2009-11-07 06:09:38 | [diff] [blame] | 645 | if (!SupportsSeccompSandbox(g_proc_fd)) { |
[email protected] | e8c916a | 2009-11-04 17:52:47 | [diff] [blame] | 646 | // There are a good number of users who cannot use the seccomp sandbox |
| 647 | // (e.g. because their distribution does not enable seccomp mode by |
| 648 | // default). While we would prefer to deny execution in this case, it |
| 649 | // seems more realistic to continue in degraded mode. |
[email protected] | 1b5d28f | 2010-02-18 15:53:36 | [diff] [blame] | 650 | LOG(ERROR) << "WARNING! This machine lacks support needed for the " |
| 651 | "Seccomp sandbox. Running renderers with Seccomp " |
| 652 | "sandboxing disabled."; |
[email protected] | e8c916a | 2009-11-04 17:52:47 | [diff] [blame] | 653 | } else { |
| 654 | LOG(INFO) << "Enabling experimental Seccomp sandbox."; |
| 655 | } |
| 656 | } |
[email protected] | 36ea6c6f | 2010-03-17 20:08:01 | [diff] [blame] | 657 | #endif // SECCOMP_SANDBOX |
[email protected] | e8c916a | 2009-11-04 17:52:47 | [diff] [blame] | 658 | |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 659 | Zygote zygote; |
[email protected] | c548be2 | 2010-03-08 12:55:57 | [diff] [blame] | 660 | // This function call can return multiple times, once per fork(). |
[email protected] | cc8f146 | 2009-06-12 17:36:55 | [diff] [blame] | 661 | return zygote.ProcessRequests(); |
| 662 | } |