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

Side by Side Diff: sandbox/linux/bpf_dsl/bpf_dsl_more_unittest.cc

Issue 759343002: sandbox: sandbox_linux_unittests enforces TSYNC on ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding header Created 6 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bpf_dsl/bpf_dsl.h" 5 #include "sandbox/linux/bpf_dsl/bpf_dsl.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <pthread.h> 9 #include <pthread.h>
10 #include <sched.h> 10 #include <sched.h>
(...skipping 12 matching lines...) Expand all
23 #define __user 23 #define __user
24 #endif 24 #endif
25 #include <linux/futex.h> 25 #include <linux/futex.h>
26 26
27 #include "base/bind.h" 27 #include "base/bind.h"
28 #include "base/logging.h" 28 #include "base/logging.h"
29 #include "base/macros.h" 29 #include "base/macros.h"
30 #include "base/memory/scoped_ptr.h" 30 #include "base/memory/scoped_ptr.h"
31 #include "base/posix/eintr_wrapper.h" 31 #include "base/posix/eintr_wrapper.h"
32 #include "base/synchronization/waitable_event.h" 32 #include "base/synchronization/waitable_event.h"
33 #include "base/sys_info.h"
33 #include "base/threading/thread.h" 34 #include "base/threading/thread.h"
34 #include "build/build_config.h" 35 #include "build/build_config.h"
35 #include "sandbox/linux/bpf_dsl/policy.h" 36 #include "sandbox/linux/bpf_dsl/policy.h"
36 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" 37 #include "sandbox/linux/seccomp-bpf/bpf_tests.h"
37 #include "sandbox/linux/seccomp-bpf/die.h" 38 #include "sandbox/linux/seccomp-bpf/die.h"
38 #include "sandbox/linux/seccomp-bpf/errorcode.h" 39 #include "sandbox/linux/seccomp-bpf/errorcode.h"
39 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h" 40 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h"
40 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 41 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
41 #include "sandbox/linux/seccomp-bpf/syscall.h" 42 #include "sandbox/linux/seccomp-bpf/syscall.h"
42 #include "sandbox/linux/seccomp-bpf/trap.h" 43 #include "sandbox/linux/seccomp-bpf/trap.h"
(...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 } 2247 }
2247 2248
2248 BPF_ASSERT(event->IsSignaled()); 2249 BPF_ASSERT(event->IsSignaled());
2249 2250
2250 BlacklistNanosleepPolicy::AssertNanosleepFails(); 2251 BlacklistNanosleepPolicy::AssertNanosleepFails();
2251 2252
2252 return NULL; 2253 return NULL;
2253 } 2254 }
2254 2255
2255 SANDBOX_TEST(SandboxBPF, Tsync) { 2256 SANDBOX_TEST(SandboxBPF, Tsync) {
2256 if (!(SandboxBPF::SupportsSeccompSandbox( 2257 const bool supports_multi_threaded = SandboxBPF::SupportsSeccompSandbox(
2257 SandboxBPF::SeccompLevel::MULTI_THREADED))) { 2258 SandboxBPF::SeccompLevel::MULTI_THREADED);
2259 // On ChromeOS tsync is mandatory.
Jorge Lucangeli Obes 2014/12/03 17:19:38 Nit: "Chrome OS" with a space.
leecam 2014/12/03 17:25:23 Done.
2260 #if defined(OS_CHROMEOS)
2261 if (base::SysInfo::IsRunningOnChromeOS()) {
2262 BPF_ASSERT_EQ(true, supports_multi_threaded);
2263 }
2264 // else a ChromeOS build not running on a ChromeOS device e.g. chrome bots.
Jorge Lucangeli Obes 2014/12/03 17:19:38 Same nit, and you probably want to capitalize Chro
leecam 2014/12/03 17:25:23 Done.
2265 // In this case fall through.
2266 #endif
2267 if (!supports_multi_threaded) {
2258 return; 2268 return;
2259 } 2269 }
2260 2270
2261 base::WaitableEvent event(true, false); 2271 base::WaitableEvent event(true, false);
2262 2272
2263 // Create a thread on which to invoke the blocked syscall. 2273 // Create a thread on which to invoke the blocked syscall.
2264 pthread_t thread; 2274 pthread_t thread;
2265 BPF_ASSERT_EQ( 2275 BPF_ASSERT_EQ(
2266 0, pthread_create(&thread, NULL, &TsyncApplyToTwoThreadsFunc, &event)); 2276 0, pthread_create(&thread, NULL, &TsyncApplyToTwoThreadsFunc, &event));
2267 2277
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 BPF_ASSERT_EQ(ENOSYS, errno); 2387 BPF_ASSERT_EQ(ENOSYS, errno);
2378 2388
2379 BPF_ASSERT_EQ(-1, syscall(__NR_setgid, 300)); 2389 BPF_ASSERT_EQ(-1, syscall(__NR_setgid, 300));
2380 BPF_ASSERT_EQ(EPERM, errno); 2390 BPF_ASSERT_EQ(EPERM, errno);
2381 } 2391 }
2382 2392
2383 } // namespace 2393 } // namespace
2384 2394
2385 } // namespace bpf_dsl 2395 } // namespace bpf_dsl
2386 } // namespace sandbox 2396 } // 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