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 #ifndef SANDBOX_LINUX_SECCOMP_BPF_TRAP_H__ | 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_TRAP_H__ |
6 #define SANDBOX_LINUX_SECCOMP_BPF_TRAP_H__ | 6 #define SANDBOX_LINUX_SECCOMP_BPF_TRAP_H__ |
7 | 7 |
8 #include <signal.h> | 8 #include <signal.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 const void* aux; | 60 const void* aux; |
61 bool safe; | 61 bool safe; |
62 bool operator<(const TrapKey&) const; | 62 bool operator<(const TrapKey&) const; |
63 }; | 63 }; |
64 typedef std::map<TrapKey, uint16_t> TrapIds; | 64 typedef std::map<TrapKey, uint16_t> TrapIds; |
65 | 65 |
66 // Our constructor is private. A shared global instance is created | 66 // Our constructor is private. A shared global instance is created |
67 // automatically as needed. | 67 // automatically as needed. |
68 Trap(); | 68 Trap(); |
69 | 69 |
70 // The destructor is unimplemented as destroying this object would | 70 // The destructor is unimplemented. Don't ever attempt to destruct this |
71 // break subsequent system calls that trigger a SIGSYS. | 71 // object. It'll break subsequent system calls that trigger a SIGSYS. |
72 ~Trap() = delete; | 72 ~Trap(); |
73 | 73 |
74 static void SigSysAction(int nr, siginfo_t* info, void* void_context); | 74 static void SigSysAction(int nr, siginfo_t* info, void* void_context); |
75 | 75 |
76 // Make sure that SigSys is not inlined in order to get slightly better crash | 76 // Make sure that SigSys is not inlined in order to get slightly better crash |
77 // dumps. | 77 // dumps. |
78 void SigSys(int nr, siginfo_t* info, void* void_context) | 78 void SigSys(int nr, siginfo_t* info, void* void_context) |
79 __attribute__((noinline)); | 79 __attribute__((noinline)); |
80 bool SandboxDebuggingAllowedByUser() const; | 80 bool SandboxDebuggingAllowedByUser() const; |
81 | 81 |
82 // We have a global singleton that handles all of our SIGSYS traps. This | 82 // We have a global singleton that handles all of our SIGSYS traps. This |
83 // variable must never be deallocated after it has been set up initially, as | 83 // variable must never be deallocated after it has been set up initially, as |
84 // there is no way to reset in-kernel BPF filters that generate SIGSYS | 84 // there is no way to reset in-kernel BPF filters that generate SIGSYS |
85 // events. | 85 // events. |
86 static Trap* global_trap_; | 86 static Trap* global_trap_; |
87 | 87 |
88 TrapIds trap_ids_; // Maps from TrapKeys to numeric ids | 88 TrapIds trap_ids_; // Maps from TrapKeys to numeric ids |
89 TrapKey* trap_array_; // Array of TrapKeys indexed by ids | 89 TrapKey* trap_array_; // Array of TrapKeys indexed by ids |
90 size_t trap_array_size_; // Currently used size of array | 90 size_t trap_array_size_; // Currently used size of array |
91 size_t trap_array_capacity_; // Currently allocated capacity of array | 91 size_t trap_array_capacity_; // Currently allocated capacity of array |
92 bool has_unsafe_traps_; // Whether unsafe traps have been enabled | 92 bool has_unsafe_traps_; // Whether unsafe traps have been enabled |
93 | 93 |
94 // Copying and assigning is unimplemented. It doesn't make sense for a | 94 // Copying and assigning is unimplemented. It doesn't make sense for a |
95 // singleton. | 95 // singleton. |
96 DISALLOW_COPY_AND_ASSIGN(Trap); | 96 DISALLOW_COPY_AND_ASSIGN(Trap); |
97 }; | 97 }; |
98 | 98 |
99 } // namespace sandbox | 99 } // namespace sandbox |
100 | 100 |
101 #endif // SANDBOX_LINUX_SECCOMP_BPF_TRAP_H__ | 101 #endif // SANDBOX_LINUX_SECCOMP_BPF_TRAP_H__ |
OLD | NEW |