Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: sandbox/linux/services/yama_unittests.cc

Issue 374933002: Revert of Disable yama on 3.2 kernels with 32bit userland and 64bit kernel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/posix/eintr_wrapper.h" 14 #include "base/posix/eintr_wrapper.h"
15 #include "base/strings/string_util.h"
16 #include "base/sys_info.h"
17 #include "sandbox/linux/services/scoped_process.h" 15 #include "sandbox/linux/services/scoped_process.h"
18 #include "sandbox/linux/services/yama.h" 16 #include "sandbox/linux/services/yama.h"
19 #include "sandbox/linux/tests/unit_tests.h" 17 #include "sandbox/linux/tests/unit_tests.h"
20 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
21 19
22 namespace sandbox { 20 namespace sandbox {
23 21
24 namespace { 22 namespace {
25 23
26 bool HasLinux32Bug() {
27 #if defined(__i386__)
28 // On 3.2 kernels, yama doesn't work for 32-bit binaries on 64-bit kernels.
29 // This is fixed in 3.4.
30 bool is_kernel_64bit =
31 base::SysInfo::OperatingSystemArchitecture() == "x86_64";
32 bool is_linux = base::SysInfo::OperatingSystemName() == "Linux";
33 bool is_3_dot_2 = StartsWithASCII(
34 base::SysInfo::OperatingSystemVersion(), "3.2", /*case_sensitive=*/false);
35 if (is_kernel_64bit && is_linux && is_3_dot_2)
36 return true;
37 #endif // defined(__i386__)
38 return false;
39 }
40
41 bool CanPtrace(pid_t pid) { 24 bool CanPtrace(pid_t pid) {
42 int ret; 25 int ret;
43 ret = ptrace(PTRACE_ATTACH, pid, NULL, NULL); 26 ret = ptrace(PTRACE_ATTACH, pid, NULL, NULL);
44 if (ret == -1) { 27 if (ret == -1) {
45 CHECK_EQ(EPERM, errno); 28 CHECK_EQ(EPERM, errno);
46 return false; 29 return false;
47 } 30 }
48 // Wait for the process to be stopped so that it can be detached. 31 // Wait for the process to be stopped so that it can be detached.
49 siginfo_t process_info; 32 siginfo_t process_info;
50 int wait_ret = HANDLE_EINTR(waitid(P_PID, pid, &process_info, WSTOPPED)); 33 int wait_ret = HANDLE_EINTR(waitid(P_PID, pid, &process_info, WSTOPPED));
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (Yama::IsEnforcing()) { 143 if (Yama::IsEnforcing()) {
161 // Check that process1 is protected by Yama, even though it has 144 // Check that process1 is protected by Yama, even though it has
162 // been created from a process that disabled Yama. 145 // been created from a process that disabled Yama.
163 CHECK(!CanSubProcessPtrace(process1.GetPid())); 146 CHECK(!CanSubProcessPtrace(process1.GetPid()));
164 } 147 }
165 } 148 }
166 149
167 } // namespace 150 } // namespace
168 151
169 } // namespace sandbox 152 } // namespace sandbox
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698