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) { |
| 22 err_ = SECCOMP_RET_TRACE + (err & SECCOMP_RET_DATA); |
| 23 error_type_ = ET_SIMPLE; |
| 24 break; |
| 25 } |
21 SANDBOX_DIE("Invalid use of ErrorCode object"); | 26 SANDBOX_DIE("Invalid use of ErrorCode object"); |
22 } | 27 } |
23 } | 28 } |
24 | 29 |
25 ErrorCode::ErrorCode(Trap::TrapFnc fnc, const void* aux, bool safe, uint16_t id) | 30 ErrorCode::ErrorCode(Trap::TrapFnc fnc, const void* aux, bool safe, uint16_t id) |
26 : error_type_(ET_TRAP), | 31 : error_type_(ET_TRAP), |
27 fnc_(fnc), | 32 fnc_(fnc), |
28 aux_(const_cast<void*>(aux)), | 33 aux_(const_cast<void*>(aux)), |
29 safe_(safe), | 34 safe_(safe), |
30 err_(SECCOMP_RET_TRAP + id) {} | 35 err_(SECCOMP_RET_TRAP + id) {} |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } else { | 100 } else { |
96 return false; | 101 return false; |
97 } | 102 } |
98 } else { | 103 } else { |
99 SANDBOX_DIE("Corrupted ErrorCode"); | 104 SANDBOX_DIE("Corrupted ErrorCode"); |
100 } | 105 } |
101 } | 106 } |
102 } | 107 } |
103 | 108 |
104 } // namespace sandbox | 109 } // namespace sandbox |
OLD | NEW |