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/die.h" | 5 #include "sandbox/linux/seccomp-bpf/die.h" |
6 #include "sandbox/linux/seccomp-bpf/errorcode.h" | 6 #include "sandbox/linux/seccomp-bpf/errorcode.h" |
7 | 7 |
8 namespace sandbox { | 8 namespace sandbox { |
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 if ((err & ~SECCOMP_RET_DATA) == ERR_TRACE) { | 21 if ((err & ~SECCOMP_RET_DATA) == ERR_TRACE) { |
22 err_ = SECCOMP_RET_TRACE + (err & SECCOMP_RET_DATA); | 22 err_ = SECCOMP_RET_TRACE + (err & SECCOMP_RET_DATA); |
23 error_type_ = ET_SIMPLE; | 23 error_type_ = ET_SIMPLE; |
24 break; | 24 break; |
25 } | 25 } |
26 SANDBOX_DIE("Invalid use of ErrorCode object"); | 26 SANDBOX_DIE("Invalid use of ErrorCode object"); |
27 } | 27 } |
28 } | 28 } |
29 | 29 |
30 ErrorCode::ErrorCode(Trap::TrapFnc fnc, const void* aux, bool safe, uint16_t id) | 30 ErrorCode::ErrorCode(Trap::TrapFnc fnc, const void* aux, bool safe) |
31 : error_type_(ET_TRAP), | 31 : error_type_(ET_TRAP), |
32 fnc_(fnc), | 32 fnc_(fnc), |
33 aux_(const_cast<void*>(aux)), | 33 aux_(const_cast<void*>(aux)), |
34 safe_(safe), | 34 safe_(safe), |
35 err_(SECCOMP_RET_TRAP + id) {} | 35 err_(SECCOMP_RET_TRAP + Trap::MakeTrap(fnc, aux, safe)) { |
| 36 } |
36 | 37 |
37 ErrorCode::ErrorCode(int argno, | 38 ErrorCode::ErrorCode(int argno, |
38 ArgType width, | 39 ArgType width, |
39 uint64_t mask, | 40 uint64_t mask, |
40 uint64_t value, | 41 uint64_t value, |
41 const ErrorCode* passed, | 42 const ErrorCode* passed, |
42 const ErrorCode* failed) | 43 const ErrorCode* failed) |
43 : error_type_(ET_COND), | 44 : error_type_(ET_COND), |
44 mask_(mask), | 45 mask_(mask), |
45 value_(value), | 46 value_(value), |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } else { | 98 } else { |
98 return false; | 99 return false; |
99 } | 100 } |
100 } else { | 101 } else { |
101 SANDBOX_DIE("Corrupted ErrorCode"); | 102 SANDBOX_DIE("Corrupted ErrorCode"); |
102 } | 103 } |
103 } | 104 } |
104 } | 105 } |
105 | 106 |
106 } // namespace sandbox | 107 } // namespace sandbox |
OLD | NEW |