| 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 <ostream> | 5 #include <ostream> |
| 6 | 6 |
| 7 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" | 7 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" |
| 8 #include "sandbox/linux/seccomp-bpf/verifier.h" | 8 #include "sandbox/linux/seccomp-bpf/verifier.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 ErrorCode SyntheticPolicy(int sysno) { | 150 ErrorCode SyntheticPolicy(int sysno) { |
| 151 if (sysno < static_cast<int>(MIN_SYSCALL) || | 151 if (sysno < static_cast<int>(MIN_SYSCALL) || |
| 152 sysno > static_cast<int>(MAX_SYSCALL)) { | 152 sysno > static_cast<int>(MAX_SYSCALL)) { |
| 153 // FIXME: we should really not have to do that in a trivial policy. | 153 // FIXME: we should really not have to do that in a trivial policy. |
| 154 return ErrorCode(ENOSYS); | 154 return ErrorCode(ENOSYS); |
| 155 } | 155 } |
| 156 | 156 |
| 157 // TODO(jorgelo): remove this restriction once crbug.com/141694 is fixed. | 157 // TODO(jorgelo): remove this restriction once crbug.com/141694 is fixed. |
| 158 #if defined(__arm__) | 158 #if defined(__arm__) |
| 159 if (sysno > kArmPublicSysnoCeiling) | 159 if (sysno > kArmPublicSysnoCeiling) |
| 160 return ENOSYS; | 160 return ErrorCode(ENOSYS); |
| 161 #endif | 161 #endif |
| 162 | 162 |
| 163 // TODO(markus): allow calls to write(). This should start working as soon | 163 // TODO(markus): allow calls to write(). This should start working as soon |
| 164 // as we switch to the new code generator. Currently we are blowing up, | 164 // as we switch to the new code generator. Currently we are blowing up, |
| 165 // because our jumptable is getting too big. | 165 // because our jumptable is getting too big. |
| 166 if (sysno == __NR_exit_group /* || sysno == __NR_write */) { | 166 if (sysno == __NR_exit_group /* || sysno == __NR_write */) { |
| 167 // exit_group() is special, we really need it to work. | 167 // exit_group() is special, we really need it to work. |
| 168 // write() is needed for BPF_ASSERT() to report a useful error message. | 168 // write() is needed for BPF_ASSERT() to report a useful error message. |
| 169 return ErrorCode(ErrorCode::ERR_ALLOWED); | 169 return ErrorCode(ErrorCode::ERR_ALLOWED); |
| 170 } else { | 170 } else { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 194 // exit_group() is special | 194 // exit_group() is special |
| 195 continue; | 195 continue; |
| 196 } | 196 } |
| 197 errno = 0; | 197 errno = 0; |
| 198 BPF_ASSERT(syscall(syscall_number) == -1); | 198 BPF_ASSERT(syscall(syscall_number) == -1); |
| 199 BPF_ASSERT(errno == SysnoToRandomErrno(syscall_number)); | 199 BPF_ASSERT(errno == SysnoToRandomErrno(syscall_number)); |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace | 203 } // namespace |
| OLD | NEW |