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