Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: sandbox/linux/seccomp-bpf/trap.h

Issue 291063002: Fix misuses of DISALLOW_IMPLICIT_CONSTRUCTORS() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sort declarations according to Google style guide Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Once unsafe traps are enabled, the sandbox is essentially compromised. 56 // Once unsafe traps are enabled, the sandbox is essentially compromised.
57 // But this is still a very useful feature for debugging purposes. Use with 57 // But this is still a very useful feature for debugging purposes. Use with
58 // care. This feature is availably only if enabled by the user (see above). 58 // care. This feature is availably only if enabled by the user (see above).
59 // Returns "true", if unsafe traps were turned on. 59 // Returns "true", if unsafe traps were turned on.
60 static bool EnableUnsafeTrapsInSigSysHandler(); 60 static bool EnableUnsafeTrapsInSigSysHandler();
61 61
62 // Returns the ErrorCode associate with a particular trap id. 62 // Returns the ErrorCode associate with a particular trap id.
63 static ErrorCode ErrorCodeFromTrapId(uint16_t id); 63 static ErrorCode ErrorCodeFromTrapId(uint16_t id);
64 64
65 private: 65 private:
66 // The destructor is unimplemented. Don't ever attempt to destruct this
67 // object. It'll break subsequent system calls that trigger a SIGSYS.
68 ~Trap();
69
70 struct TrapKey { 66 struct TrapKey {
71 TrapKey(TrapFnc f, const void* a, bool s) : fnc(f), aux(a), safe(s) {} 67 TrapKey(TrapFnc f, const void* a, bool s) : fnc(f), aux(a), safe(s) {}
72 TrapFnc fnc; 68 TrapFnc fnc;
73 const void* aux; 69 const void* aux;
74 bool safe; 70 bool safe;
75 bool operator<(const TrapKey&) const; 71 bool operator<(const TrapKey&) const;
76 }; 72 };
77 typedef std::map<TrapKey, uint16_t> TrapIds; 73 typedef std::map<TrapKey, uint16_t> TrapIds;
78 74
75 // Our constructor is private. A shared global instance is created
76 // automatically as needed.
77 Trap();
78
79 // The destructor is unimplemented. Don't ever attempt to destruct this
80 // object. It'll break subsequent system calls that trigger a SIGSYS.
81 ~Trap();
82
79 // 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
80 // and have them internally call GetInstance(). This is a little more 84 // and have them internally call GetInstance(). This is a little more
81 // convenient than having each caller obtain short-lived reference to the 85 // convenient than having each caller obtain short-lived reference to the
82 // singleton. 86 // singleton.
83 // 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,
84 // but avoid instantiating it, if it doesn't exist yet 88 // but avoid instantiating it, if it doesn't exist yet
85 // (e.g. ErrorCodeFromTrapId()). 89 // (e.g. ErrorCodeFromTrapId()).
86 static Trap* GetInstance(); 90 static Trap* GetInstance();
87 static void SigSysAction(int nr, siginfo_t* info, void* void_context); 91 static void SigSysAction(int nr, siginfo_t* info, void* void_context);
88 92
89 // Make sure that SigSys is not inlined in order to get slightly better crash 93 // Make sure that SigSys is not inlined in order to get slightly better crash
90 // dumps. 94 // dumps.
91 void SigSys(int nr, siginfo_t* info, void* void_context) 95 void SigSys(int nr, siginfo_t* info, void* void_context)
92 __attribute__((noinline)); 96 __attribute__((noinline));
93 ErrorCode MakeTrapImpl(TrapFnc fnc, const void* aux, bool safe); 97 ErrorCode MakeTrapImpl(TrapFnc fnc, const void* aux, bool safe);
94 bool SandboxDebuggingAllowedByUser() const; 98 bool SandboxDebuggingAllowedByUser() const;
95 99
96 // We have a global singleton that handles all of our SIGSYS traps. This 100 // We have a global singleton that handles all of our SIGSYS traps. This
97 // variable must never be deallocated after it has been set up initially, as 101 // variable must never be deallocated after it has been set up initially, as
98 // there is no way to reset in-kernel BPF filters that generate SIGSYS 102 // there is no way to reset in-kernel BPF filters that generate SIGSYS
99 // events. 103 // events.
100 static Trap* global_trap_; 104 static Trap* global_trap_;
101 105
102 TrapIds trap_ids_; // Maps from TrapKeys to numeric ids 106 TrapIds trap_ids_; // Maps from TrapKeys to numeric ids
103 ErrorCode* trap_array_; // Array of ErrorCodes indexed by ids 107 ErrorCode* trap_array_; // Array of ErrorCodes indexed by ids
104 size_t trap_array_size_; // Currently used size of array 108 size_t trap_array_size_; // Currently used size of array
105 size_t trap_array_capacity_; // Currently allocated capacity of array 109 size_t trap_array_capacity_; // Currently allocated capacity of array
106 bool has_unsafe_traps_; // Whether unsafe traps have been enabled 110 bool has_unsafe_traps_; // Whether unsafe traps have been enabled
107 111
108 // Our constructor is private. A shared global instance is created
109 // automatically as needed.
110 // Copying and assigning is unimplemented. It doesn't make sense for a 112 // Copying and assigning is unimplemented. It doesn't make sense for a
111 // singleton. 113 // singleton.
112 DISALLOW_IMPLICIT_CONSTRUCTORS(Trap); 114 DISALLOW_COPY_AND_ASSIGN(Trap);
113 }; 115 };
114 116
115 } // namespace sandbox 117 } // namespace sandbox
116 118
117 #endif // SANDBOX_LINUX_SECCOMP_BPF_TRAP_H__ 119 #endif // SANDBOX_LINUX_SECCOMP_BPF_TRAP_H__
OLDNEW
« no previous file with comments | « content/common/sandbox_linux/sandbox_linux.h ('k') | sandbox/linux/suid/client/setuid_sandbox_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698