| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <errno.h> | 5 #include <errno.h> |
| 6 #include <fcntl.h> | 6 #include <fcntl.h> |
| 7 #include <sys/ptrace.h> | 7 #include <sys/ptrace.h> |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 bool HasLinux32Bug() { | 26 bool HasLinux32Bug() { |
| 27 #if defined(__i386__) | 27 #if defined(__i386__) |
| 28 // On 3.2 kernels, yama doesn't work for 32-bit binaries on 64-bit kernels. | 28 // On 3.2 kernels, yama doesn't work for 32-bit binaries on 64-bit kernels. |
| 29 // This is fixed in 3.4. | 29 // This is fixed in 3.4. |
| 30 bool is_kernel_64bit = | 30 bool is_kernel_64bit = |
| 31 base::SysInfo::OperatingSystemArchitecture() == "x86_64"; | 31 base::SysInfo::OperatingSystemArchitecture() == "x86_64"; |
| 32 bool is_linux = base::SysInfo::OperatingSystemName() == "Linux"; | 32 bool is_linux = base::SysInfo::OperatingSystemName() == "Linux"; |
| 33 bool is_3_dot_2 = StartsWithASCII( | 33 bool is_3_dot_2 = base::StartsWithASCII( |
| 34 base::SysInfo::OperatingSystemVersion(), "3.2", /*case_sensitive=*/false); | 34 base::SysInfo::OperatingSystemVersion(), "3.2", /*case_sensitive=*/false); |
| 35 if (is_kernel_64bit && is_linux && is_3_dot_2) | 35 if (is_kernel_64bit && is_linux && is_3_dot_2) |
| 36 return true; | 36 return true; |
| 37 #endif // defined(__i386__) | 37 #endif // defined(__i386__) |
| 38 return false; | 38 return false; |
| 39 } | 39 } |
| 40 | 40 |
| 41 bool CanPtrace(pid_t pid) { | 41 bool CanPtrace(pid_t pid) { |
| 42 int ret; | 42 int ret; |
| 43 ret = ptrace(PTRACE_ATTACH, pid, NULL, NULL); | 43 ret = ptrace(PTRACE_ATTACH, pid, NULL, NULL); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 if (Yama::IsEnforcing()) { | 163 if (Yama::IsEnforcing()) { |
| 164 // Check that process1 is protected by Yama, even though it has | 164 // Check that process1 is protected by Yama, even though it has |
| 165 // been created from a process that disabled Yama. | 165 // been created from a process that disabled Yama. |
| 166 CHECK(!CanSubProcessPtrace(process1.GetPid())); | 166 CHECK(!CanSubProcessPtrace(process1.GetPid())); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace | 170 } // namespace |
| 171 | 171 |
| 172 } // namespace sandbox | 172 } // namespace sandbox |
| OLD | NEW |