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

Side by Side Diff: components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc

Issue 239703011: Reland: Add seccomp sandbox for non-SFI NaCl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/nacl/loader/nonsfi/nonsfi_sandbox.h"
6
7 #include <errno.h>
8 #include <fcntl.h>
9 #include <pthread.h>
10 #include <sched.h>
11 #include <signal.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <sys/mman.h>
15 #include <sys/prctl.h>
16 #include <sys/ptrace.h>
17 #include <sys/socket.h>
18 #include <sys/syscall.h>
19 #include <sys/types.h>
20 #include <sys/wait.h>
21 #include <unistd.h>
22
23 #include "base/bind.h"
24 #include "base/callback.h"
25 #include "base/compiler_specific.h"
26 #include "base/files/scoped_file.h"
27 #include "base/logging.h"
28 #include "base/posix/eintr_wrapper.h"
29 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h"
30 #include "sandbox/linux/seccomp-bpf/bpf_tests.h"
31
32 namespace {
33
34 void DoPipe(base::ScopedFD* fds) {
35 int tmp_fds[2];
36 BPF_ASSERT_EQ(0, pipe(tmp_fds));
37 fds[0].reset(tmp_fds[0]);
38 fds[1].reset(tmp_fds[1]);
39 }
40
41 void DoSocketpair(base::ScopedFD* fds) {
42 int tmp_fds[2];
43 BPF_ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_STREAM, 0, tmp_fds));
44 fds[0].reset(tmp_fds[0]);
45 fds[1].reset(tmp_fds[1]);
46 }
47
48 TEST(NaClNonSfiSandboxTest, BPFIsSupported) {
49 bool seccomp_bpf_supported = false;
50 // Seccomp-BPF tests die under TSAN v2. See http://crbug.com/356588
51 #if !defined(THREAD_SANITIZER)
52 seccomp_bpf_supported = (
53 sandbox::SandboxBPF::SupportsSeccompSandbox(-1) ==
54 sandbox::SandboxBPF::STATUS_AVAILABLE);
55 #endif
56
57 if (!seccomp_bpf_supported) {
58 LOG(ERROR) << "Seccomp BPF is not supported, these tests "
59 << "will pass without running";
60 }
61 }
62
63 BPF_DEATH_TEST(NaClNonSfiSandboxTest, invalid_sysno,
64 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
65 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
66 syscall(999);
67 }
68
69 const int kExpectedValue = 123;
70
71 void* SetValueInThread(void* test_val_ptr) {
72 *reinterpret_cast<int*>(test_val_ptr) = kExpectedValue;
73 return NULL;
74 }
75
76 // To make this test pass, we need to allow sched_getaffinity and
77 // mmap. We just disable this test not to complicate the sandbox.
78 BPF_TEST(NaClNonSfiSandboxTest, DISABLE_ON_ASAN(clone_by_pthread_create),
79 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
80 // clone call for thread creation is allowed.
81 pthread_t th;
82 int test_val = 42;
83 BPF_ASSERT_EQ(0, pthread_create(&th, NULL, &SetValueInThread, &test_val));
84 BPF_ASSERT_EQ(0, pthread_join(th, NULL));
85 BPF_ASSERT_EQ(kExpectedValue, test_val);
86 }
87
88 int DoFork() {
89 // Call clone() to do a fork().
90 const int pid = syscall(__NR_clone, SIGCHLD, NULL);
91 if (pid == 0)
92 _exit(0);
93 return pid;
94 }
95
96 // The sanity check for DoFork without the sandbox.
97 TEST(NaClNonSfiSandboxTest, DoFork) {
98 const int pid = DoFork();
99 ASSERT_LT(0, pid);
100 int status;
101 ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0)));
102 ASSERT_TRUE(WIFEXITED(status));
103 ASSERT_EQ(0, WEXITSTATUS(status));
104 }
105
106 // Then, try this in the sandbox.
107 BPF_DEATH_TEST(NaClNonSfiSandboxTest, clone_for_fork,
108 DEATH_MESSAGE(sandbox::GetCloneErrorMessageContentForTests()),
109 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
110 DoFork();
111 }
112
113 BPF_TEST(NaClNonSfiSandboxTest, prctl_SET_NAME,
114 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
115 errno = 0;
116 BPF_ASSERT_EQ(-1, syscall(__NR_prctl, PR_SET_NAME, "foo"));
117 BPF_ASSERT_EQ(EPERM, errno);
118 }
119
120 BPF_DEATH_TEST(NaClNonSfiSandboxTest, prctl_SET_DUMPABLE,
121 DEATH_MESSAGE(sandbox::GetPrctlErrorMessageContentForTests()),
122 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
123 syscall(__NR_prctl, PR_SET_DUMPABLE, 1UL);
124 }
125
126 BPF_TEST(NaClNonSfiSandboxTest, socketcall_allowed,
127 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
128 base::ScopedFD fds[2];
129 struct msghdr msg = {};
130 struct iovec iov;
131 std::string payload("foo");
132 iov.iov_base = &payload[0];
133 iov.iov_len = payload.size();
134 msg.msg_iov = &iov;
135 msg.msg_iovlen = 1;
136 DoSocketpair(fds);
137 BPF_ASSERT_EQ(static_cast<int>(payload.size()),
138 HANDLE_EINTR(sendmsg(fds[1].get(), &msg, 0)));
139 BPF_ASSERT_EQ(static_cast<int>(payload.size()),
140 HANDLE_EINTR(recvmsg(fds[0].get(), &msg, 0)));
141 BPF_ASSERT_EQ(0, shutdown(fds[0].get(), SHUT_RDWR));
142 }
143
144 BPF_DEATH_TEST(NaClNonSfiSandboxTest, accept,
145 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
146 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
147 accept(0, NULL, NULL);
148 }
149
150 BPF_DEATH_TEST(NaClNonSfiSandboxTest, bind,
151 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
152 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
153 bind(0, NULL, 0);
154 }
155
156 BPF_DEATH_TEST(NaClNonSfiSandboxTest, connect,
157 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
158 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
159 connect(0, NULL, 0);
160 }
161
162 BPF_DEATH_TEST(NaClNonSfiSandboxTest, getpeername,
163 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
164 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
165 getpeername(0, NULL, NULL);
166 }
167
168 BPF_DEATH_TEST(NaClNonSfiSandboxTest, getsockname,
169 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
170 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
171 struct sockaddr addr;
172 socklen_t addrlen = 0;
173 getsockname(0, &addr, &addrlen);
174 }
175
176 BPF_DEATH_TEST(NaClNonSfiSandboxTest, getsockopt,
177 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
178 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
179 getsockopt(0, 0, 0, NULL, NULL);
180 }
181
182 BPF_DEATH_TEST(NaClNonSfiSandboxTest, listen,
183 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
184 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
185 listen(0, 0);
186 }
187
188 BPF_DEATH_TEST(NaClNonSfiSandboxTest, recv,
189 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
190 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
191 recv(0, NULL, 0, 0);
192 }
193
194 BPF_DEATH_TEST(NaClNonSfiSandboxTest, recvfrom,
195 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
196 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
197 recvfrom(0, NULL, 0, 0, NULL, NULL);
198 }
199
200 BPF_DEATH_TEST(NaClNonSfiSandboxTest, send,
201 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
202 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
203 send(0, NULL, 0, 0);
204 }
205
206 BPF_DEATH_TEST(NaClNonSfiSandboxTest, sendto,
207 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
208 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
209 sendto(0, NULL, 0, 0, NULL, 0);
210 }
211
212 BPF_DEATH_TEST(NaClNonSfiSandboxTest, setsockopt,
213 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
214 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
215 setsockopt(0, 0, 0, NULL, 0);
216 }
217
218 BPF_DEATH_TEST(NaClNonSfiSandboxTest, socket,
219 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
220 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
221 socket(0, 0, 0);
222 }
223
224 #if defined(__x86_64__) || defined(__arm__)
225 BPF_DEATH_TEST(NaClNonSfiSandboxTest, socketpair,
226 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
227 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
228 int fds[2];
229 socketpair(AF_INET, SOCK_STREAM, 0, fds);
230 }
231 #endif
232
233 BPF_TEST(NaClNonSfiSandboxTest, fcntl_SETFD_allowed,
234 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
235 base::ScopedFD fds[2];
236 DoSocketpair(fds);
237 BPF_ASSERT_EQ(0, fcntl(fds[0].get(), F_SETFD, FD_CLOEXEC));
238 }
239
240 BPF_DEATH_TEST(NaClNonSfiSandboxTest, fcntl_SETFD,
241 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
242 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
243 base::ScopedFD fds[2];
244 DoSocketpair(fds);
245 fcntl(fds[0].get(), F_SETFD, 99);
246 }
247
248 BPF_TEST(NaClNonSfiSandboxTest, fcntl_GETFL_SETFL_allowed,
249 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
250 base::ScopedFD fds[2];
251 DoPipe(fds);
252 const int fd = fds[0].get();
253 BPF_ASSERT_EQ(0, fcntl(fd, F_GETFL));
254 BPF_ASSERT_EQ(0, fcntl(fd, F_SETFL, O_RDWR | O_NONBLOCK));
255 BPF_ASSERT_EQ(O_NONBLOCK, fcntl(fd, F_GETFL));
256 }
257
258 BPF_DEATH_TEST(NaClNonSfiSandboxTest, fcntl_GETFL_SETFL,
259 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
260 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
261 base::ScopedFD fds[2];
262 DoSocketpair(fds);
263 fcntl(fds[0].get(), F_SETFL, O_APPEND);
264 }
265
266 BPF_DEATH_TEST(NaClNonSfiSandboxTest, fcntl_DUPFD,
267 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
268 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
269 fcntl(0, F_DUPFD);
270 }
271
272 BPF_DEATH_TEST(NaClNonSfiSandboxTest, fcntl_DUPFD_CLOEXEC,
273 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
274 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
275 fcntl(0, F_DUPFD_CLOEXEC);
276 }
277
278 void* DoAllowedAnonymousMmap() {
279 return mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE,
280 MAP_ANONYMOUS | MAP_SHARED, -1, 0);
281 }
282
283 BPF_TEST(NaClNonSfiSandboxTest, mmap_allowed,
284 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
285 void* ptr = DoAllowedAnonymousMmap();
286 BPF_ASSERT_NE(MAP_FAILED, ptr);
287 BPF_ASSERT_EQ(0, munmap(ptr, getpagesize()));
288 }
289
290 BPF_DEATH_TEST(NaClNonSfiSandboxTest, mmap_unallowed_flag,
291 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
292 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
293 mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE,
294 MAP_ANONYMOUS | MAP_POPULATE, -1, 0);
295 }
296
297 BPF_DEATH_TEST(NaClNonSfiSandboxTest, mmap_unallowed_prot,
298 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
299 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
300 mmap(NULL, getpagesize(), PROT_READ | PROT_GROWSDOWN,
301 MAP_ANONYMOUS, -1, 0);
302 }
303
304 // TODO(hamaji): Disallow RWX mmap.
305 #if 0
306 BPF_DEATH_TEST(NaClNonSfiSandboxTest, mmap_rwx,
307 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
308 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
309 mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC,
310 MAP_ANONYMOUS, -1, 0);
311 }
312 #endif
313
314 BPF_TEST(NaClNonSfiSandboxTest, mprotect_allowed,
315 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
316 void* ptr = DoAllowedAnonymousMmap();
317 BPF_ASSERT_NE(MAP_FAILED, ptr);
318 BPF_ASSERT_EQ(0, mprotect(ptr, getpagesize(), PROT_READ));
319 BPF_ASSERT_EQ(0, munmap(ptr, getpagesize()));
320 }
321
322 BPF_DEATH_TEST(NaClNonSfiSandboxTest, mprotect_unallowed_prot,
323 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
324 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
325 // We have tested DoAllowedAnonymousMmap is allowed in
326 // mmap_allowed, so we can make sure the following mprotect call
327 // kills the process.
328 void* ptr = DoAllowedAnonymousMmap();
329 BPF_ASSERT_NE(MAP_FAILED, ptr);
330 mprotect(ptr, getpagesize(), PROT_READ | PROT_GROWSDOWN);
331 }
332
333 BPF_TEST(NaClNonSfiSandboxTest, brk,
334 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
335 char* next_brk = static_cast<char*>(sbrk(0)) + getpagesize();
336 // The kernel interface must return zero for brk.
337 BPF_ASSERT_EQ(0, syscall(__NR_brk, next_brk));
338 // The libc wrapper translates it to ENOMEM.
339 errno = 0;
340 BPF_ASSERT_EQ(-1, brk(next_brk));
341 BPF_ASSERT_EQ(ENOMEM, errno);
342 }
343
344 #if defined(__i386__) || defined(__arm__)
345 BPF_TEST(NaClNonSfiSandboxTest, getegid32_EPERM,
346 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
347 errno = 0;
348 BPF_ASSERT_EQ(-1, syscall(__NR_getegid32));
349 BPF_ASSERT_EQ(EPERM, errno);
350 }
351
352 BPF_TEST(NaClNonSfiSandboxTest, geteuid32_EPERM,
353 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
354 errno = 0;
355 BPF_ASSERT_EQ(-1, syscall(__NR_geteuid32));
356 BPF_ASSERT_EQ(EPERM, errno);
357 }
358
359 BPF_TEST(NaClNonSfiSandboxTest, getgid32_EPERM,
360 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
361 errno = 0;
362 BPF_ASSERT_EQ(-1, syscall(__NR_getgid32));
363 BPF_ASSERT_EQ(EPERM, errno);
364 }
365
366 BPF_TEST(NaClNonSfiSandboxTest, getuid32_EPERM,
367 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
368 errno = 0;
369 BPF_ASSERT_EQ(-1, syscall(__NR_getuid32));
370 BPF_ASSERT_EQ(EPERM, errno);
371 }
372
373 BPF_DEATH_TEST(NaClNonSfiSandboxTest, getegid_SIGSYS,
374 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
375 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
376 syscall(__NR_getegid);
377 }
378
379 BPF_DEATH_TEST(NaClNonSfiSandboxTest, geteuid_SIGSYS,
380 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
381 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
382 syscall(__NR_geteuid);
383 }
384
385 BPF_DEATH_TEST(NaClNonSfiSandboxTest, getgid_SIGSYS,
386 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
387 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
388 syscall(__NR_getgid);
389 }
390
391 BPF_DEATH_TEST(NaClNonSfiSandboxTest, getuid_SIGSYS,
392 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
393 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
394 syscall(__NR_getuid);
395 }
396 #endif
397
398 #if defined(__x86_64__)
399 BPF_TEST(NaClNonSfiSandboxTest, getegid_EPERM,
400 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
401 errno = 0;
402 BPF_ASSERT_EQ(-1, syscall(__NR_getegid));
403 BPF_ASSERT_EQ(EPERM, errno);
404 }
405
406 BPF_TEST(NaClNonSfiSandboxTest, geteuid_EPERM,
407 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
408 errno = 0;
409 BPF_ASSERT_EQ(-1, syscall(__NR_geteuid));
410 BPF_ASSERT_EQ(EPERM, errno);
411 }
412
413 BPF_TEST(NaClNonSfiSandboxTest, getgid_EPERM,
414 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
415 errno = 0;
416 BPF_ASSERT_EQ(-1, syscall(__NR_getgid));
417 BPF_ASSERT_EQ(EPERM, errno);
418 }
419
420 BPF_TEST(NaClNonSfiSandboxTest, getuid_EPERM,
421 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
422 errno = 0;
423 BPF_ASSERT_EQ(-1, syscall(__NR_getuid));
424 BPF_ASSERT_EQ(EPERM, errno);
425 }
426 #endif
427
428 BPF_TEST(NaClNonSfiSandboxTest, getpid_EPERM,
429 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
430 errno = 0;
431 BPF_ASSERT_EQ(-1, syscall(__NR_getpid));
432 BPF_ASSERT_EQ(EPERM, errno);
433 }
434
435 BPF_TEST(NaClNonSfiSandboxTest, ioctl_EPERM,
436 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
437 errno = 0;
438 BPF_ASSERT_EQ(-1, syscall(__NR_ioctl));
439 BPF_ASSERT_EQ(EPERM, errno);
440 }
441
442 BPF_TEST(NaClNonSfiSandboxTest, readlink_EPERM,
443 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
444 errno = 0;
445 BPF_ASSERT_EQ(-1, syscall(__NR_readlink));
446 BPF_ASSERT_EQ(EPERM, errno);
447 }
448
449 BPF_TEST(NaClNonSfiSandboxTest, madvise_EPERM,
450 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
451 errno = 0;
452 BPF_ASSERT_EQ(-1, syscall(__NR_madvise));
453 BPF_ASSERT_EQ(EPERM, errno);
454 }
455
456 BPF_TEST(NaClNonSfiSandboxTest, open_EPERM,
457 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
458 errno = 0;
459 BPF_ASSERT_EQ(-1, syscall(__NR_open));
460 BPF_ASSERT_EQ(EPERM, errno);
461 }
462
463 BPF_TEST(NaClNonSfiSandboxTest, ptrace_EPERM,
464 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
465 errno = 0;
466 BPF_ASSERT_EQ(-1, syscall(__NR_ptrace));
467 BPF_ASSERT_EQ(EPERM, errno);
468 }
469
470 BPF_TEST(NaClNonSfiSandboxTest, set_robust_list_EPERM,
471 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
472 errno = 0;
473 BPF_ASSERT_EQ(-1, syscall(__NR_set_robust_list));
474 BPF_ASSERT_EQ(EPERM, errno);
475 }
476
477 #if defined(__i386__) || defined(__x86_64__)
478 BPF_TEST(NaClNonSfiSandboxTest, time_EPERM,
479 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
480 errno = 0;
481 BPF_ASSERT_EQ(-1, syscall(__NR_time));
482 BPF_ASSERT_EQ(EPERM, errno);
483 }
484 #endif
485
486 } // namespace
OLDNEW
« no previous file with comments | « components/nacl/loader/nonsfi/nonsfi_sandbox_sigsys_unittest.cc ('k') | sandbox/linux/sandbox_linux.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698