| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/sandbox_linux/sandbox_linux.h" | 5 #include "content/common/sandbox_linux/sandbox_linux.h" |
| 6 | 6 |
| 7 #include <dirent.h> | 7 #include <dirent.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <sys/resource.h> | 10 #include <sys/resource.h> |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 247 |
| 248 return sandbox_status_flags_; | 248 return sandbox_status_flags_; |
| 249 } | 249 } |
| 250 | 250 |
| 251 // Threads are counted via /proc/self/task. This is a little hairy because of | 251 // Threads are counted via /proc/self/task. This is a little hairy because of |
| 252 // PID namespaces and existing sandboxes, so "self" must really be used instead | 252 // PID namespaces and existing sandboxes, so "self" must really be used instead |
| 253 // of using the pid. | 253 // of using the pid. |
| 254 bool LinuxSandbox::IsSingleThreaded() const { | 254 bool LinuxSandbox::IsSingleThreaded() const { |
| 255 base::ScopedFD proc_fd(OpenProc(proc_fd_)); | 255 base::ScopedFD proc_fd(OpenProc(proc_fd_)); |
| 256 | 256 |
| 257 CHECK(proc_fd.is_valid()) << "Could not count threads, the sandbox was not " | 257 // Could not count threads, the sandbox was not pre-initialized properly. |
| 258 << "pre-initialized properly."; | 258 CHECK(proc_fd.is_valid()); |
| 259 | 259 |
| 260 const bool is_single_threaded = | 260 const bool is_single_threaded = |
| 261 sandbox::ThreadHelpers::IsSingleThreaded(proc_fd.get()); | 261 sandbox::ThreadHelpers::IsSingleThreaded(proc_fd.get()); |
| 262 | 262 |
| 263 return is_single_threaded; | 263 return is_single_threaded; |
| 264 } | 264 } |
| 265 | 265 |
| 266 bool LinuxSandbox::seccomp_bpf_started() const { | 266 bool LinuxSandbox::seccomp_bpf_started() const { |
| 267 return seccomp_bpf_started_; | 267 return seccomp_bpf_started_; |
| 268 } | 268 } |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 451 |
| 452 void LinuxSandbox::StopThreadAndEnsureNotCounted(base::Thread* thread) const { | 452 void LinuxSandbox::StopThreadAndEnsureNotCounted(base::Thread* thread) const { |
| 453 DCHECK(thread); | 453 DCHECK(thread); |
| 454 base::ScopedFD proc_fd(OpenProc(proc_fd_)); | 454 base::ScopedFD proc_fd(OpenProc(proc_fd_)); |
| 455 PCHECK(proc_fd.is_valid()); | 455 PCHECK(proc_fd.is_valid()); |
| 456 CHECK( | 456 CHECK( |
| 457 sandbox::ThreadHelpers::StopThreadAndWatchProcFS(proc_fd.get(), thread)); | 457 sandbox::ThreadHelpers::StopThreadAndWatchProcFS(proc_fd.get(), thread)); |
| 458 } | 458 } |
| 459 | 459 |
| 460 } // namespace content | 460 } // namespace content |
| OLD | NEW |