| 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 "sandbox/linux/seccomp-bpf/verifier.h" | 5 #include "sandbox/linux/seccomp-bpf/verifier.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| 11 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" | 11 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" |
| 12 #include "sandbox/linux/bpf_dsl/bpf_dsl_impl.h" |
| 12 #include "sandbox/linux/bpf_dsl/policy_compiler.h" | 13 #include "sandbox/linux/bpf_dsl/policy_compiler.h" |
| 13 #include "sandbox/linux/seccomp-bpf/errorcode.h" | 14 #include "sandbox/linux/seccomp-bpf/errorcode.h" |
| 14 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h" | 15 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h" |
| 15 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | 16 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
| 16 #include "sandbox/linux/seccomp-bpf/syscall_iterator.h" | 17 #include "sandbox/linux/seccomp-bpf/syscall_iterator.h" |
| 17 | 18 |
| 18 namespace sandbox { | 19 namespace sandbox { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 if (!(sysnum & 0x40000000u)) { | 334 if (!(sysnum & 0x40000000u)) { |
| 334 continue; | 335 continue; |
| 335 } | 336 } |
| 336 #else | 337 #else |
| 337 if (sysnum & 0x40000000u) { | 338 if (sysnum & 0x40000000u) { |
| 338 continue; | 339 continue; |
| 339 } | 340 } |
| 340 #endif | 341 #endif |
| 341 #endif | 342 #endif |
| 342 ErrorCode code = iter.IsValid(sysnum) | 343 ErrorCode code = iter.IsValid(sysnum) |
| 343 ? policy.EvaluateSyscall(compiler, sysnum) | 344 ? policy.EvaluateSyscall(sysnum)->Compile(compiler) |
| 344 : policy.InvalidSyscall(compiler); | 345 : policy.InvalidSyscall()->Compile(compiler); |
| 345 if (!VerifyErrorCode(compiler, program, &data, code, code, err)) { | 346 if (!VerifyErrorCode(compiler, program, &data, code, code, err)) { |
| 346 return false; | 347 return false; |
| 347 } | 348 } |
| 348 } | 349 } |
| 349 return true; | 350 return true; |
| 350 } | 351 } |
| 351 | 352 |
| 352 uint32_t Verifier::EvaluateBPF(const std::vector<struct sock_filter>& program, | 353 uint32_t Verifier::EvaluateBPF(const std::vector<struct sock_filter>& program, |
| 353 const struct arch_seccomp_data& data, | 354 const struct arch_seccomp_data& data, |
| 354 const char** err) { | 355 const char** err) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 break; | 392 break; |
| 392 default: | 393 default: |
| 393 *err = "Unexpected instruction in BPF program"; | 394 *err = "Unexpected instruction in BPF program"; |
| 394 break; | 395 break; |
| 395 } | 396 } |
| 396 } | 397 } |
| 397 return 0; | 398 return 0; |
| 398 } | 399 } |
| 399 | 400 |
| 400 } // namespace sandbox | 401 } // namespace sandbox |
| OLD | NEW |