| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BPF_DSL_TRAP_REGISTRY_H_ | 5 #ifndef SANDBOX_LINUX_BPF_DSL_TRAP_REGISTRY_H_ |
| 6 #define SANDBOX_LINUX_BPF_DSL_TRAP_REGISTRY_H_ | 6 #define SANDBOX_LINUX_BPF_DSL_TRAP_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 typedef intptr_t (*TrapFnc)(const struct arch_seccomp_data& args, void* aux); | 42 typedef intptr_t (*TrapFnc)(const struct arch_seccomp_data& args, void* aux); |
| 43 | 43 |
| 44 // Add registers the specified trap handler tuple and returns a | 44 // Add registers the specified trap handler tuple and returns a |
| 45 // non-zero trap ID that uniquely identifies the tuple for the life | 45 // non-zero trap ID that uniquely identifies the tuple for the life |
| 46 // time of the trap registry. If the same tuple is registered | 46 // time of the trap registry. If the same tuple is registered |
| 47 // multiple times, the same value will be returned each time. | 47 // multiple times, the same value will be returned each time. |
| 48 virtual uint16_t Add(TrapFnc fnc, const void* aux, bool safe) = 0; | 48 virtual uint16_t Add(TrapFnc fnc, const void* aux, bool safe) = 0; |
| 49 | 49 |
| 50 // EnableUnsafeTraps tries to enable unsafe traps and returns | 50 // EnableUnsafeTraps tries to enable unsafe traps and returns |
| 51 // whether it was successful. This is a one-way operation. | 51 // whether it was successful. This is a one-way operation. |
| 52 // | |
| 53 // CAUTION: Enabling unsafe traps effectively defeats the security | |
| 54 // guarantees provided by the sandbox policy. TrapRegistry | |
| 55 // implementations should ensure unsafe traps are only enabled | |
| 56 // during testing. | |
| 57 virtual bool EnableUnsafeTraps() = 0; | 52 virtual bool EnableUnsafeTraps() = 0; |
| 58 | 53 |
| 59 protected: | 54 protected: |
| 60 TrapRegistry() {} | 55 TrapRegistry() {} |
| 61 | 56 |
| 62 // TrapRegistry's destructor is intentionally non-virtual so that | 57 // TrapRegistry's destructor is intentionally non-virtual so that |
| 63 // implementations can omit their destructor. Instead we protect against | 58 // implementations can omit their destructor. Instead we protect against |
| 64 // misuse by marking it protected. | 59 // misuse by marking it protected. |
| 65 ~TrapRegistry() {} | 60 ~TrapRegistry() {} |
| 66 | 61 |
| 67 DISALLOW_COPY_AND_ASSIGN(TrapRegistry); | 62 DISALLOW_COPY_AND_ASSIGN(TrapRegistry); |
| 68 }; | 63 }; |
| 69 | 64 |
| 70 } // namespace bpf_dsl | 65 } // namespace bpf_dsl |
| 71 } // namespace sandbox | 66 } // namespace sandbox |
| 72 | 67 |
| 73 #endif // SANDBOX_LINUX_BPF_DSL_TRAP_REGISTRY_H_ | 68 #endif // SANDBOX_LINUX_BPF_DSL_TRAP_REGISTRY_H_ |
| OLD | NEW |