@@ -164,45 +164,33 @@ void SetSigProcMask(__sanitizer_sigset_t *set, __sanitizer_sigset_t *oldset) {
164
164
CHECK_EQ (0 , internal_sigprocmask (SIG_SETMASK, set, oldset));
165
165
}
166
166
167
- // Deletes the specified signal from newset, if it is not present in oldset
168
- // Equivalently: newset[signum] = newset[signum] & oldset[signum]
169
- static void KeepUnblocked (__sanitizer_sigset_t &newset,
170
- __sanitizer_sigset_t &oldset, int signum) {
171
- if (!internal_sigismember (&oldset, signum))
172
- internal_sigdelset (&newset, signum);
173
- }
174
-
175
167
// Block asynchronous signals
176
168
void BlockSignals (__sanitizer_sigset_t *oldset) {
177
- __sanitizer_sigset_t currentset;
178
- SetSigProcMask (NULL , ¤tset);
179
-
180
- __sanitizer_sigset_t newset;
181
- internal_sigfillset (&newset);
169
+ __sanitizer_sigset_t set;
170
+ internal_sigfillset (&set);
182
171
# if SANITIZER_LINUX && !SANITIZER_ANDROID
183
172
// Glibc uses SIGSETXID signal during setuid call. If this signal is blocked
184
173
// on any thread, setuid call hangs.
185
174
// See test/sanitizer_common/TestCases/Linux/setuid.c.
186
- KeepUnblocked (newset, currentset , 33 );
175
+ internal_sigdelset (&set , 33 );
187
176
# endif
188
177
# if SANITIZER_LINUX
189
178
// Seccomp-BPF-sandboxed processes rely on SIGSYS to handle trapped syscalls.
190
179
// If this signal is blocked, such calls cannot be handled and the process may
191
180
// hang.
192
- KeepUnblocked (newset, currentset , 31 );
181
+ internal_sigdelset (&set , 31 );
193
182
194
183
// Don't block synchronous signals
195
- // but also don't unblock signals that the user had deliberately blocked.
196
- KeepUnblocked (newset, currentset, SIGSEGV);
197
- KeepUnblocked (newset, currentset, SIGBUS);
198
- KeepUnblocked (newset, currentset, SIGILL);
199
- KeepUnblocked (newset, currentset, SIGTRAP);
200
- KeepUnblocked (newset, currentset, SIGABRT);
201
- KeepUnblocked (newset, currentset, SIGFPE);
202
- KeepUnblocked (newset, currentset, SIGPIPE);
184
+ internal_sigdelset (&set, SIGSEGV);
185
+ internal_sigdelset (&set, SIGBUS);
186
+ internal_sigdelset (&set, SIGILL);
187
+ internal_sigdelset (&set, SIGTRAP);
188
+ internal_sigdelset (&set, SIGABRT);
189
+ internal_sigdelset (&set, SIGFPE);
190
+ internal_sigdelset (&set, SIGPIPE);
203
191
# endif
204
192
205
- SetSigProcMask (&newset , oldset);
193
+ SetSigProcMask (&set , oldset);
206
194
}
207
195
208
196
ScopedBlockSignals::ScopedBlockSignals (__sanitizer_sigset_t *copy) {
0 commit comments