| 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/bpf_dsl/policy_compiler.h" | 5 #include "sandbox/linux/bpf_dsl/policy_compiler.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <linux/filter.h> | 8 #include <linux/filter.h> |
| 9 #include <sys/syscall.h> | 9 #include <sys/syscall.h> |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // ultimately do so for us. | 69 // ultimately do so for us. |
| 70 int err = reinterpret_cast<intptr_t>(aux) & SECCOMP_RET_DATA; | 70 int err = reinterpret_cast<intptr_t>(aux) & SECCOMP_RET_DATA; |
| 71 return -err; | 71 return -err; |
| 72 } | 72 } |
| 73 | 73 |
| 74 intptr_t BPFFailure(const struct arch_seccomp_data&, void* aux) { | 74 intptr_t BPFFailure(const struct arch_seccomp_data&, void* aux) { |
| 75 SANDBOX_DIE(static_cast<char*>(aux)); | 75 SANDBOX_DIE(static_cast<char*>(aux)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 bool HasUnsafeTraps(const SandboxBPFDSLPolicy* policy) { | 78 bool HasUnsafeTraps(const SandboxBPFDSLPolicy* policy) { |
| 79 for (uint32_t sysnum : SyscallSet::All()) { | 79 for (uint32_t sysnum : SyscallSet::ValidOnly()) { |
| 80 if (SyscallSet::IsValid(sysnum) && | 80 if (policy->EvaluateSyscall(sysnum)->HasUnsafeTraps()) { |
| 81 policy->EvaluateSyscall(sysnum)->HasUnsafeTraps()) { | |
| 82 return true; | 81 return true; |
| 83 } | 82 } |
| 84 } | 83 } |
| 85 return policy->InvalidSyscall()->HasUnsafeTraps(); | 84 return policy->InvalidSyscall()->HasUnsafeTraps(); |
| 86 } | 85 } |
| 87 | 86 |
| 88 } // namespace | 87 } // namespace |
| 89 | 88 |
| 90 struct PolicyCompiler::Range { | 89 struct PolicyCompiler::Range { |
| 91 Range(uint32_t f, const ErrorCode& e) : from(f), err(e) {} | 90 Range(uint32_t f, const ErrorCode& e) : from(f), err(e) {} |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 &*conds_.insert(passed).first, | 513 &*conds_.insert(passed).first, |
| 515 &*conds_.insert(failed).first); | 514 &*conds_.insert(failed).first); |
| 516 } | 515 } |
| 517 | 516 |
| 518 ErrorCode PolicyCompiler::Kill(const char* msg) { | 517 ErrorCode PolicyCompiler::Kill(const char* msg) { |
| 519 return Trap(BPFFailure, const_cast<char*>(msg)); | 518 return Trap(BPFFailure, const_cast<char*>(msg)); |
| 520 } | 519 } |
| 521 | 520 |
| 522 } // namespace bpf_dsl | 521 } // namespace bpf_dsl |
| 523 } // namespace sandbox | 522 } // namespace sandbox |
| OLD | NEW |