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

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

Issue 1093843002: Revert of Introduce sys_sigprocmask and sys_sigaction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « sandbox/linux/seccomp-bpf/syscall.h ('k') | sandbox/linux/seccomp-bpf/trap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdint.h> 9 #include <stdint.h>
9 10
10 #include <map> 11 #include <map>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "sandbox/linux/bpf_dsl/trap_registry.h" 14 #include "sandbox/linux/bpf_dsl/trap_registry.h"
14 #include "sandbox/linux/system_headers/linux_signal.h"
15 #include "sandbox/sandbox_export.h" 15 #include "sandbox/sandbox_export.h"
16 16
17 namespace sandbox { 17 namespace sandbox {
18 18
19 // The Trap class allows a BPF filter program to branch out to user space by 19 // The Trap class allows a BPF filter program to branch out to user space by
20 // raising a SIGSYS signal. 20 // raising a SIGSYS signal.
21 // N.B.: This class does not perform any synchronization operations. If 21 // N.B.: This class does not perform any synchronization operations. If
22 // modifications are made to any of the traps, it is the caller's 22 // modifications are made to any of the traps, it is the caller's
23 // responsibility to ensure that this happens in a thread-safe fashion. 23 // responsibility to ensure that this happens in a thread-safe fashion.
24 // Preferably, that means that no other threads should be running at that 24 // Preferably, that means that no other threads should be running at that
(...skipping 25 matching lines...) Expand all
50 typedef std::map<TrapKey, uint16_t> TrapIds; 50 typedef std::map<TrapKey, uint16_t> TrapIds;
51 51
52 // Our constructor is private. A shared global instance is created 52 // Our constructor is private. A shared global instance is created
53 // automatically as needed. 53 // automatically as needed.
54 Trap(); 54 Trap();
55 55
56 // The destructor is unimplemented as destroying this object would 56 // The destructor is unimplemented as destroying this object would
57 // break subsequent system calls that trigger a SIGSYS. 57 // break subsequent system calls that trigger a SIGSYS.
58 ~Trap() = delete; 58 ~Trap() = delete;
59 59
60 static void SigSysAction(int nr, LinuxSigInfo* info, void* void_context); 60 static void SigSysAction(int nr, siginfo_t* info, void* void_context);
61 61
62 // Make sure that SigSys is not inlined in order to get slightly better crash 62 // Make sure that SigSys is not inlined in order to get slightly better crash
63 // dumps. 63 // dumps.
64 void SigSys(int nr, LinuxSigInfo* info, void* void_context) 64 void SigSys(int nr, siginfo_t* info, void* void_context)
65 __attribute__((noinline)); 65 __attribute__((noinline));
66 // We have a global singleton that handles all of our SIGSYS traps. This 66 // We have a global singleton that handles all of our SIGSYS traps. This
67 // variable must never be deallocated after it has been set up initially, as 67 // variable must never be deallocated after it has been set up initially, as
68 // there is no way to reset in-kernel BPF filters that generate SIGSYS 68 // there is no way to reset in-kernel BPF filters that generate SIGSYS
69 // events. 69 // events.
70 static Trap* global_trap_; 70 static Trap* global_trap_;
71 71
72 TrapIds trap_ids_; // Maps from TrapKeys to numeric ids 72 TrapIds trap_ids_; // Maps from TrapKeys to numeric ids
73 TrapKey* trap_array_; // Array of TrapKeys indexed by ids 73 TrapKey* trap_array_; // Array of TrapKeys indexed by ids
74 size_t trap_array_size_; // Currently used size of array 74 size_t trap_array_size_; // Currently used size of array
75 size_t trap_array_capacity_; // Currently allocated capacity of array 75 size_t trap_array_capacity_; // Currently allocated capacity of array
76 bool has_unsafe_traps_; // Whether unsafe traps have been enabled 76 bool has_unsafe_traps_; // Whether unsafe traps have been enabled
77 77
78 // Copying and assigning is unimplemented. It doesn't make sense for a 78 // Copying and assigning is unimplemented. It doesn't make sense for a
79 // singleton. 79 // singleton.
80 DISALLOW_COPY_AND_ASSIGN(Trap); 80 DISALLOW_COPY_AND_ASSIGN(Trap);
81 }; 81 };
82 82
83 } // namespace sandbox 83 } // namespace sandbox
84 84
85 #endif // SANDBOX_LINUX_SECCOMP_BPF_TRAP_H__ 85 #endif // SANDBOX_LINUX_SECCOMP_BPF_TRAP_H__
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/syscall.h ('k') | sandbox/linux/seccomp-bpf/trap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698