OLD | NEW |
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 <errno.h> | 5 #include <errno.h> |
6 #include <pthread.h> | 6 #include <pthread.h> |
7 #include <sched.h> | 7 #include <sched.h> |
8 #include <sys/prctl.h> | 8 #include <sys/prctl.h> |
9 #include <sys/syscall.h> | 9 #include <sys/syscall.h> |
10 #include <sys/time.h> | 10 #include <sys/time.h> |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 // index of that set + 1 (so that we never return a NUL errno). | 350 // index of that set + 1 (so that we never return a NUL errno). |
351 return ((sysno & ~3) >> 2) % 29 + 1; | 351 return ((sysno & ~3) >> 2) % 29 + 1; |
352 } | 352 } |
353 | 353 |
354 ErrorCode SyntheticPolicy(SandboxBPF*, int sysno, void*) { | 354 ErrorCode SyntheticPolicy(SandboxBPF*, int sysno, void*) { |
355 if (!SandboxBPF::IsValidSyscallNumber(sysno)) { | 355 if (!SandboxBPF::IsValidSyscallNumber(sysno)) { |
356 // FIXME: we should really not have to do that in a trivial policy | 356 // FIXME: we should really not have to do that in a trivial policy |
357 return ErrorCode(ENOSYS); | 357 return ErrorCode(ENOSYS); |
358 } | 358 } |
359 | 359 |
360 // TODO(jorgelo): remove this once the new code generator lands. | |
361 #if defined(__arm__) | |
362 if (sysno > static_cast<int>(MAX_PUBLIC_SYSCALL)) { | |
363 return ErrorCode(ENOSYS); | |
364 } | |
365 #endif | |
366 | |
367 if (sysno == __NR_exit_group || sysno == __NR_write) { | 360 if (sysno == __NR_exit_group || sysno == __NR_write) { |
368 // exit_group() is special, we really need it to work. | 361 // exit_group() is special, we really need it to work. |
369 // write() is needed for BPF_ASSERT() to report a useful error message. | 362 // write() is needed for BPF_ASSERT() to report a useful error message. |
370 return ErrorCode(ErrorCode::ERR_ALLOWED); | 363 return ErrorCode(ErrorCode::ERR_ALLOWED); |
371 } else { | 364 } else { |
372 return ErrorCode(SysnoToRandomErrno(sysno)); | 365 return ErrorCode(SysnoToRandomErrno(sysno)); |
373 } | 366 } |
374 } | 367 } |
375 | 368 |
376 BPF_TEST(SandboxBPF, SyntheticPolicy, SyntheticPolicy) { | 369 BPF_TEST(SandboxBPF, SyntheticPolicy, SyntheticPolicy) { |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1777 &pid) == -EPERM); | 1770 &pid) == -EPERM); |
1778 } | 1771 } |
1779 | 1772 |
1780 BPF_TEST(SandboxBPF, PthreadEquality, PthreadPolicyEquality) { PthreadTest(); } | 1773 BPF_TEST(SandboxBPF, PthreadEquality, PthreadPolicyEquality) { PthreadTest(); } |
1781 | 1774 |
1782 BPF_TEST(SandboxBPF, PthreadBitMask, PthreadPolicyBitMask) { PthreadTest(); } | 1775 BPF_TEST(SandboxBPF, PthreadBitMask, PthreadPolicyBitMask) { PthreadTest(); } |
1783 | 1776 |
1784 } // namespace | 1777 } // namespace |
1785 | 1778 |
1786 } // namespace sandbox | 1779 } // namespace sandbox |
OLD | NEW |