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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // We only have a very small number of methods. We opt to make them static | 83 // We only have a very small number of methods. We opt to make them static |
84 // and have them internally call GetInstance(). This is a little more | 84 // and have them internally call GetInstance(). This is a little more |
85 // convenient than having each caller obtain short-lived reference to the | 85 // convenient than having each caller obtain short-lived reference to the |
86 // singleton. | 86 // singleton. |
87 // It also gracefully deals with methods that should check for the singleton, | 87 // It also gracefully deals with methods that should check for the singleton, |
88 // but avoid instantiating it, if it doesn't exist yet | 88 // but avoid instantiating it, if it doesn't exist yet |
89 // (e.g. ErrorCodeFromTrapId()). | 89 // (e.g. ErrorCodeFromTrapId()). |
90 static Trap *GetInstance(); | 90 static Trap *GetInstance(); |
91 static void SigSysAction(int nr, siginfo_t *info, void *void_context); | 91 static void SigSysAction(int nr, siginfo_t *info, void *void_context); |
92 | 92 |
93 void SigSys(int nr, siginfo_t *info, void *void_context); | 93 // Make sure that SigSys is not inlined in order to get slightly better crash |
| 94 // dumps. |
| 95 void SigSys(int nr, siginfo_t *info, void *void_context) |
| 96 __attribute__ ((noinline)); |
94 ErrorCode MakeTrapImpl(TrapFnc fnc, const void *aux, bool safe); | 97 ErrorCode MakeTrapImpl(TrapFnc fnc, const void *aux, bool safe); |
95 bool SandboxDebuggingAllowedByUser() const; | 98 bool SandboxDebuggingAllowedByUser() const; |
96 | 99 |
97 | 100 |
98 | 101 |
99 // We have a global singleton that handles all of our SIGSYS traps. This | 102 // We have a global singleton that handles all of our SIGSYS traps. This |
100 // variable must never be deallocated after it has been set up initially, as | 103 // variable must never be deallocated after it has been set up initially, as |
101 // there is no way to reset in-kernel BPF filters that generate SIGSYS | 104 // there is no way to reset in-kernel BPF filters that generate SIGSYS |
102 // events. | 105 // events. |
103 static Trap *global_trap_; | 106 static Trap *global_trap_; |
104 | 107 |
105 TrapIds trap_ids_; // Maps from TrapKeys to numeric ids | 108 TrapIds trap_ids_; // Maps from TrapKeys to numeric ids |
106 ErrorCode *trap_array_; // Array of ErrorCodes indexed by ids | 109 ErrorCode *trap_array_; // Array of ErrorCodes indexed by ids |
107 size_t trap_array_size_; // Currently used size of array | 110 size_t trap_array_size_; // Currently used size of array |
108 size_t trap_array_capacity_; // Currently allocated capacity of array | 111 size_t trap_array_capacity_; // Currently allocated capacity of array |
109 bool has_unsafe_traps_; // Whether unsafe traps have been enabled | 112 bool has_unsafe_traps_; // Whether unsafe traps have been enabled |
110 | 113 |
111 // Our constructor is private. A shared global instance is created | 114 // Our constructor is private. A shared global instance is created |
112 // automatically as needed. | 115 // automatically as needed. |
113 // Copying and assigning is unimplemented. It doesn't make sense for a | 116 // Copying and assigning is unimplemented. It doesn't make sense for a |
114 // singleton. | 117 // singleton. |
115 DISALLOW_IMPLICIT_CONSTRUCTORS(Trap); | 118 DISALLOW_IMPLICIT_CONSTRUCTORS(Trap); |
116 }; | 119 }; |
117 | 120 |
118 } // namespace playground2 | 121 } // namespace playground2 |
119 | 122 |
120 #endif // SANDBOX_LINUX_SECCOMP_BPF_TRAP_H__ | 123 #endif // SANDBOX_LINUX_SECCOMP_BPF_TRAP_H__ |
OLD | NEW |