| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <dlfcn.h> | 5 #include <dlfcn.h> |
| 6 #include <fcntl.h> | 6 #include <fcntl.h> |
| 7 #include <pthread.h> | 7 #include <pthread.h> |
| 8 #include <sys/epoll.h> | 8 #include <sys/epoll.h> |
| 9 #include <sys/prctl.h> | 9 #include <sys/prctl.h> |
| 10 #include <sys/signal.h> | 10 #include <sys/signal.h> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "base/sys_info.h" | 34 #include "base/sys_info.h" |
| 35 #include "base/unix_domain_socket_posix.h" | 35 #include "base/unix_domain_socket_posix.h" |
| 36 #include "build/build_config.h" | 36 #include "build/build_config.h" |
| 37 | 37 |
| 38 #include "chrome/browser/zygote_host_linux.h" | 38 #include "chrome/browser/zygote_host_linux.h" |
| 39 #include "chrome/common/chrome_descriptors.h" | 39 #include "chrome/common/chrome_descriptors.h" |
| 40 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
| 41 #include "chrome/common/main_function_params.h" | 41 #include "chrome/common/main_function_params.h" |
| 42 #include "chrome/common/pepper_plugin_registry.h" | 42 #include "chrome/common/pepper_plugin_registry.h" |
| 43 #include "chrome/common/process_watcher.h" | 43 #include "chrome/common/process_watcher.h" |
| 44 #include "chrome/common/result_codes.h" |
| 44 #include "chrome/common/sandbox_methods_linux.h" | 45 #include "chrome/common/sandbox_methods_linux.h" |
| 45 | 46 |
| 46 #include "media/base/media.h" | 47 #include "media/base/media.h" |
| 47 | 48 |
| 48 #include "skia/ext/SkFontHost_fontconfig_control.h" | 49 #include "skia/ext/SkFontHost_fontconfig_control.h" |
| 49 | 50 |
| 50 #include "seccompsandbox/sandbox.h" | 51 #include "seccompsandbox/sandbox.h" |
| 51 | 52 |
| 52 #include "unicode/timezone.h" | 53 #include "unicode/timezone.h" |
| 53 | 54 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 if (pickle.ReadInt(&iter, &kind)) { | 161 if (pickle.ReadInt(&iter, &kind)) { |
| 161 switch (kind) { | 162 switch (kind) { |
| 162 case ZygoteHost::kCmdFork: | 163 case ZygoteHost::kCmdFork: |
| 163 // This function call can return multiple times, once per fork(). | 164 // This function call can return multiple times, once per fork(). |
| 164 return HandleForkRequest(fd, pickle, iter, fds); | 165 return HandleForkRequest(fd, pickle, iter, fds); |
| 165 case ZygoteHost::kCmdReap: | 166 case ZygoteHost::kCmdReap: |
| 166 if (!fds.empty()) | 167 if (!fds.empty()) |
| 167 break; | 168 break; |
| 168 HandleReapRequest(fd, pickle, iter); | 169 HandleReapRequest(fd, pickle, iter); |
| 169 return false; | 170 return false; |
| 170 case ZygoteHost::kCmdDidProcessCrash: | 171 case ZygoteHost::kCmdGetTerminationStatus: |
| 171 if (!fds.empty()) | 172 if (!fds.empty()) |
| 172 break; | 173 break; |
| 173 HandleDidProcessCrash(fd, pickle, iter); | 174 HandleGetTerminationStatus(fd, pickle, iter); |
| 174 return false; | 175 return false; |
| 175 case ZygoteHost::kCmdGetSandboxStatus: | 176 case ZygoteHost::kCmdGetSandboxStatus: |
| 176 HandleGetSandboxStatus(fd, pickle, iter); | 177 HandleGetSandboxStatus(fd, pickle, iter); |
| 177 return false; | 178 return false; |
| 178 default: | 179 default: |
| 179 NOTREACHED(); | 180 NOTREACHED(); |
| 180 break; | 181 break; |
| 181 } | 182 } |
| 182 } | 183 } |
| 183 | 184 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 202 if (!actual_child) | 203 if (!actual_child) |
| 203 return; | 204 return; |
| 204 real_pids_to_sandbox_pids.erase(child); | 205 real_pids_to_sandbox_pids.erase(child); |
| 205 } else { | 206 } else { |
| 206 actual_child = child; | 207 actual_child = child; |
| 207 } | 208 } |
| 208 | 209 |
| 209 ProcessWatcher::EnsureProcessTerminated(actual_child); | 210 ProcessWatcher::EnsureProcessTerminated(actual_child); |
| 210 } | 211 } |
| 211 | 212 |
| 212 void HandleDidProcessCrash(int fd, const Pickle& pickle, void* iter) { | 213 void HandleGetTerminationStatus(int fd, const Pickle& pickle, void* iter) { |
| 213 base::ProcessHandle child; | 214 base::ProcessHandle child; |
| 214 | 215 |
| 215 if (!pickle.ReadInt(&iter, &child)) { | 216 if (!pickle.ReadInt(&iter, &child)) { |
| 216 LOG(WARNING) << "Error parsing DidProcessCrash request from browser"; | 217 LOG(WARNING) << "Error parsing GetTerminationStatus request " |
| 218 << "from browser"; |
| 217 return; | 219 return; |
| 218 } | 220 } |
| 219 | 221 |
| 220 bool child_exited; | 222 base::TerminationStatus status; |
| 221 bool did_crash; | 223 int exit_code; |
| 222 if (g_suid_sandbox_active) | 224 if (g_suid_sandbox_active) |
| 223 child = real_pids_to_sandbox_pids[child]; | 225 child = real_pids_to_sandbox_pids[child]; |
| 224 if (child) | 226 if (child) { |
| 225 did_crash = base::DidProcessCrash(&child_exited, child); | 227 status = base::GetTerminationStatus(child, &exit_code); |
| 226 else | 228 } else { |
| 227 did_crash = child_exited = false; | 229 // Assume that if we can't find the child in the sandbox, then |
| 230 // it terminated normally. |
| 231 status = base::TERMINATION_STATUS_NORMAL_TERMINATION; |
| 232 exit_code = ResultCodes::NORMAL_EXIT; |
| 233 } |
| 228 | 234 |
| 229 Pickle write_pickle; | 235 Pickle write_pickle; |
| 230 write_pickle.WriteBool(did_crash); | 236 write_pickle.WriteInt(static_cast<int>(status)); |
| 231 write_pickle.WriteBool(child_exited); | 237 write_pickle.WriteInt(exit_code); |
| 232 if (HANDLE_EINTR(write(fd, write_pickle.data(), write_pickle.size())) != | 238 if (HANDLE_EINTR(write(fd, write_pickle.data(), write_pickle.size())) != |
| 233 write_pickle.size()) { | 239 write_pickle.size()) { |
| 234 PLOG(ERROR) << "write"; | 240 PLOG(ERROR) << "write"; |
| 235 } | 241 } |
| 236 } | 242 } |
| 237 | 243 |
| 238 // This is equivalent to fork(), except that, when using the SUID | 244 // This is equivalent to fork(), except that, when using the SUID |
| 239 // sandbox, it returns the real PID of the child process as it | 245 // sandbox, it returns the real PID of the child process as it |
| 240 // appears outside the sandbox, rather than returning the PID inside | 246 // appears outside the sandbox, rather than returning the PID inside |
| 241 // the sandbox. | 247 // the sandbox. |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 VLOG(1) << "Enabling experimental Seccomp sandbox."; | 745 VLOG(1) << "Enabling experimental Seccomp sandbox."; |
| 740 sandbox_flags |= ZygoteHost::kSandboxSeccomp; | 746 sandbox_flags |= ZygoteHost::kSandboxSeccomp; |
| 741 } | 747 } |
| 742 } | 748 } |
| 743 #endif // SECCOMP_SANDBOX | 749 #endif // SECCOMP_SANDBOX |
| 744 | 750 |
| 745 Zygote zygote(sandbox_flags); | 751 Zygote zygote(sandbox_flags); |
| 746 // This function call can return multiple times, once per fork(). | 752 // This function call can return multiple times, once per fork(). |
| 747 return zygote.ProcessRequests(); | 753 return zygote.ProcessRequests(); |
| 748 } | 754 } |
| OLD | NEW |