| 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/sandbox_bpf.h" | 5 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
| 6 | 6 |
| 7 | 7 |
| 8 namespace playground2 { | 8 namespace playground2 { |
| 9 | 9 |
| 10 ErrorCode::ErrorCode(int err) { | 10 ErrorCode::ErrorCode(int err) { |
| 11 switch (err) { | 11 switch (err) { |
| 12 case ERR_ALLOWED: | 12 case ERR_ALLOWED: |
| 13 err_ = SECCOMP_RET_ALLOW; | 13 err_ = SECCOMP_RET_ALLOW; |
| 14 error_type_ = ET_SIMPLE; | 14 error_type_ = ET_SIMPLE; |
| 15 break; | 15 break; |
| 16 case ERR_MIN_ERRNO ... ERR_MAX_ERRNO: | 16 case ERR_MIN_ERRNO ... ERR_MAX_ERRNO: |
| 17 err_ = SECCOMP_RET_ERRNO + err; | 17 err_ = SECCOMP_RET_ERRNO + err; |
| 18 error_type_ = ET_SIMPLE; | 18 error_type_ = ET_SIMPLE; |
| 19 break; | 19 break; |
| 20 default: | 20 default: |
| 21 SANDBOX_DIE("Invalid use of ErrorCode object"); | 21 SANDBOX_DIE("Invalid use of ErrorCode object"); |
| 22 } | 22 } |
| 23 } | 23 } |
| 24 | 24 |
| 25 ErrorCode::ErrorCode(ErrorCode::TrapFnc fnc, const void *aux, uint16_t id) | 25 ErrorCode::ErrorCode(ErrorCode::TrapFnc fnc, const void *aux, bool safe, |
| 26 uint16_t id) |
| 26 : error_type_(ET_TRAP), | 27 : error_type_(ET_TRAP), |
| 27 fnc_(fnc), | 28 fnc_(fnc), |
| 28 aux_(const_cast<void *>(aux)), | 29 aux_(const_cast<void *>(aux)), |
| 30 safe_(safe), |
| 29 err_(SECCOMP_RET_TRAP + id) { | 31 err_(SECCOMP_RET_TRAP + id) { |
| 30 } | 32 } |
| 31 | 33 |
| 32 ErrorCode::ErrorCode(int argno, ArgType width, Operation op, uint64_t value, | 34 ErrorCode::ErrorCode(int argno, ArgType width, Operation op, uint64_t value, |
| 33 const ErrorCode *passed, const ErrorCode *failed) | 35 const ErrorCode *passed, const ErrorCode *failed) |
| 34 : error_type_(ET_COND), | 36 : error_type_(ET_COND), |
| 35 value_(value), | 37 value_(value), |
| 36 argno_(argno), | 38 argno_(argno), |
| 37 width_(width), | 39 width_(width), |
| 38 op_(op), | 40 op_(op), |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } else { | 96 } else { |
| 95 return false; | 97 return false; |
| 96 } | 98 } |
| 97 } else { | 99 } else { |
| 98 SANDBOX_DIE("Corrupted ErrorCode"); | 100 SANDBOX_DIE("Corrupted ErrorCode"); |
| 99 } | 101 } |
| 100 } | 102 } |
| 101 } | 103 } |
| 102 | 104 |
| 103 } // namespace | 105 } // namespace |
| OLD | NEW |