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 "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h" | 5 #include "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <linux/futex.h> | 8 #include <linux/futex.h> |
9 #include <sched.h> | 9 #include <sched.h> |
10 #include <signal.h> | 10 #include <signal.h> |
11 #include <string.h> | 11 #include <string.h> |
| 12 #include <sys/prctl.h> |
12 #include <sys/socket.h> | 13 #include <sys/socket.h> |
13 #include <sys/stat.h> | 14 #include <sys/stat.h> |
14 #include <sys/syscall.h> | 15 #include <sys/syscall.h> |
15 #include <sys/time.h> | 16 #include <sys/time.h> |
16 #include <sys/types.h> | 17 #include <sys/types.h> |
17 #include <sys/wait.h> | 18 #include <sys/wait.h> |
18 #include <unistd.h> | 19 #include <unistd.h> |
19 | 20 |
20 #include "base/files/scoped_file.h" | 21 #include "base/files/scoped_file.h" |
21 #include "base/macros.h" | 22 #include "base/macros.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 256 |
256 BPF_DEATH_TEST_C(BaselinePolicy, | 257 BPF_DEATH_TEST_C(BaselinePolicy, |
257 FutexWithRequeuePriorityInheritencePrivate, | 258 FutexWithRequeuePriorityInheritencePrivate, |
258 DEATH_MESSAGE(GetFutexErrorMessageContentForTests()), | 259 DEATH_MESSAGE(GetFutexErrorMessageContentForTests()), |
259 BaselinePolicy) { | 260 BaselinePolicy) { |
260 syscall(__NR_futex, NULL, FUTEX_CMP_REQUEUE_PI_PRIVATE, 0, NULL, NULL, 0); | 261 syscall(__NR_futex, NULL, FUTEX_CMP_REQUEUE_PI_PRIVATE, 0, NULL, NULL, 0); |
261 _exit(1); | 262 _exit(1); |
262 } | 263 } |
263 #endif // !defined(OS_ANDROID) | 264 #endif // !defined(OS_ANDROID) |
264 | 265 |
| 266 BPF_TEST_C(BaselinePolicy, PrctlDumpable, BaselinePolicy) { |
| 267 const int is_dumpable = prctl(PR_GET_DUMPABLE, 0, 0, 0, 0); |
| 268 BPF_ASSERT(is_dumpable == 1 || is_dumpable == 0); |
| 269 const int prctl_ret = prctl(PR_SET_DUMPABLE, is_dumpable, 0, 0, 0, 0); |
| 270 BPF_ASSERT_EQ(0, prctl_ret); |
| 271 } |
| 272 |
| 273 // Workaround incomplete Android headers. |
| 274 #if !defined(PR_CAPBSET_READ) |
| 275 #define PR_CAPBSET_READ 23 |
| 276 #endif |
| 277 |
| 278 BPF_DEATH_TEST_C(BaselinePolicy, |
| 279 PrctlSigsys, |
| 280 DEATH_MESSAGE(GetPrctlErrorMessageContentForTests()), |
| 281 BaselinePolicy) { |
| 282 prctl(PR_CAPBSET_READ, 0, 0, 0, 0); |
| 283 _exit(1); |
| 284 } |
| 285 |
265 } // namespace | 286 } // namespace |
266 | 287 |
267 } // namespace sandbox | 288 } // namespace sandbox |
OLD | NEW |