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