OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "sandbox/linux/services/namespace_utils.h" | 5 #include "sandbox/linux/services/namespace_utils.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <sched.h> | 8 #include <sched.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <sys/wait.h> | 10 #include <sys/wait.h> |
(...skipping 26 matching lines...) Expand all Loading... | |
37 return; | 37 return; |
38 } | 38 } |
39 | 39 |
40 const uid_t uid = getuid(); | 40 const uid_t uid = getuid(); |
41 const gid_t gid = getgid(); | 41 const gid_t gid = getgid(); |
42 | 42 |
43 const pid_t pid = | 43 const pid_t pid = |
44 base::ForkWithFlags(CLONE_NEWUSER | SIGCHLD, nullptr, nullptr); | 44 base::ForkWithFlags(CLONE_NEWUSER | SIGCHLD, nullptr, nullptr); |
45 ASSERT_NE(-1, pid); | 45 ASSERT_NE(-1, pid); |
46 if (pid == 0) { | 46 if (pid == 0) { |
47 RAW_CHECK(getuid() != uid); | 47 RAW_CHECK(getuid() != uid); |
jln (very slow on Chromium)
2015/02/02 18:54:45
These can be CHECKs (just need to _exit and not ex
rickyz (no longer on Chrome)
2015/02/02 21:35:31
Looks like WriteToIdMapFile not being async-signal
jln (very slow on Chromium)
2015/02/03 01:14:30
I don't think this code here needs to be async saf
| |
48 NamespaceUtils::WriteToIdMapFile("/proc/self/uid_map", uid); | 48 RAW_CHECK(NamespaceUtils::WriteToIdMapFile("/proc/self/uid_map", uid)); |
49 RAW_CHECK(getuid() == uid); | 49 RAW_CHECK(getuid() == uid); |
50 | 50 |
51 RAW_CHECK(getgid() != gid); | 51 RAW_CHECK(getgid() != gid); |
52 NamespaceUtils::WriteToIdMapFile("/proc/self/gid_map", gid); | 52 RAW_CHECK(NamespaceUtils::WriteToIdMapFile("/proc/self/gid_map", gid)); |
53 RAW_CHECK(getgid() == gid); | 53 RAW_CHECK(getgid() == gid); |
54 | 54 |
55 _exit(0); | 55 _exit(0); |
56 } | 56 } |
57 | 57 |
58 int status = 42; | 58 int status = 42; |
59 SANDBOX_ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0))); | 59 SANDBOX_ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0))); |
60 SANDBOX_ASSERT_EQ(0, status); | 60 SANDBOX_ASSERT_EQ(0, status); |
61 } | 61 } |
62 | 62 |
63 } // namespace. | 63 } // namespace. |
64 | 64 |
65 } // namespace sandbox. | 65 } // namespace sandbox. |
OLD | NEW |