| 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 <fcntl.h> | 5 #include <fcntl.h> |
| 6 #include <sys/stat.h> | 6 #include <sys/stat.h> |
| 7 #include <sys/types.h> | 7 #include <sys/types.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/eintr_wrapper.h" | 10 #include "base/eintr_wrapper.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 int LinuxSandbox::GetStatus() const { | 151 int LinuxSandbox::GetStatus() const { |
| 152 CHECK(pre_initialized_); | 152 CHECK(pre_initialized_); |
| 153 int sandbox_flags = 0; | 153 int sandbox_flags = 0; |
| 154 if (setuid_sandbox_client_->IsSandboxed()) { | 154 if (setuid_sandbox_client_->IsSandboxed()) { |
| 155 sandbox_flags |= kSandboxLinuxSUID; | 155 sandbox_flags |= kSandboxLinuxSUID; |
| 156 if (setuid_sandbox_client_->IsInNewPIDNamespace()) | 156 if (setuid_sandbox_client_->IsInNewPIDNamespace()) |
| 157 sandbox_flags |= kSandboxLinuxPIDNS; | 157 sandbox_flags |= kSandboxLinuxPIDNS; |
| 158 if (setuid_sandbox_client_->IsInNewNETNamespace()) | 158 if (setuid_sandbox_client_->IsInNewNETNamespace()) |
| 159 sandbox_flags |= kSandboxLinuxNetNS; | 159 sandbox_flags |= kSandboxLinuxNetNS; |
| 160 } | 160 } |
| 161 if (seccomp_legacy_supported() && | 161 |
| 162 ShouldEnableSeccompLegacy(switches::kRendererProcess)) { | 162 if (seccomp_bpf_supported() && |
| 163 SandboxSeccompBpf::ShouldEnableSeccompBpf(switches::kRendererProcess)) { |
| 163 // We report whether the sandbox will be activated when renderers go | 164 // We report whether the sandbox will be activated when renderers go |
| 164 // through sandbox initialization. | 165 // through sandbox initialization. |
| 166 sandbox_flags |= kSandboxLinuxSeccompBpf; |
| 167 } |
| 168 |
| 169 // We only try to enable seccomp-legacy when seccomp-bpf is not supported |
| 170 // or not enabled. |
| 171 if (!(sandbox_flags & kSandboxLinuxSeccompBpf) && |
| 172 seccomp_legacy_supported() && |
| 173 ShouldEnableSeccompLegacy(switches::kRendererProcess)) { |
| 174 // Same here, what we report is what we will do for the renderer. |
| 165 sandbox_flags |= kSandboxLinuxSeccompLegacy; | 175 sandbox_flags |= kSandboxLinuxSeccompLegacy; |
| 166 } | 176 } |
| 167 if (seccomp_bpf_supported() && | |
| 168 SandboxSeccompBpf::ShouldEnableSeccompBpf(switches::kRendererProcess)) { | |
| 169 // Same here, what we report is what we will do for the renderer. | |
| 170 sandbox_flags |= kSandboxLinuxSeccompBpf; | |
| 171 } | |
| 172 return sandbox_flags; | 177 return sandbox_flags; |
| 173 } | 178 } |
| 174 | 179 |
| 175 bool LinuxSandbox::IsSingleThreaded() const { | 180 bool LinuxSandbox::IsSingleThreaded() const { |
| 176 // TODO(jln): re-implement this properly and use our proc_fd_ if available. | 181 // TODO(jln): re-implement this properly and use our proc_fd_ if available. |
| 177 // Possibly racy, but it's ok because this is more of a debug check to catch | 182 // Possibly racy, but it's ok because this is more of a debug check to catch |
| 178 // new threaded situations arising during development. | 183 // new threaded situations arising during development. |
| 179 int num_threads = file_util::CountFilesCreatedAfter( | 184 int num_threads = file_util::CountFilesCreatedAfter( |
| 180 FilePath("/proc/self/task"), | 185 FilePath("/proc/self/task"), |
| 181 base::Time::UnixEpoch()); | 186 base::Time::UnixEpoch()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 return seccomp_legacy_supported_; | 233 return seccomp_legacy_supported_; |
| 229 } | 234 } |
| 230 | 235 |
| 231 bool LinuxSandbox::seccomp_bpf_supported() const { | 236 bool LinuxSandbox::seccomp_bpf_supported() const { |
| 232 CHECK(pre_initialized_); | 237 CHECK(pre_initialized_); |
| 233 return seccomp_bpf_supported_; | 238 return seccomp_bpf_supported_; |
| 234 } | 239 } |
| 235 | 240 |
| 236 } // namespace content | 241 } // namespace content |
| 237 | 242 |
| OLD | NEW |