================
@@ -303,13 +377,72 @@ INTERCEPTOR(int, pthread_create, pthread_t *thread,
}
// We are intercepting sigaction in order to keep note of the set sigaction and
-// overwrite it our own function to execute the switching if the unsafe stack
-// pointer before and after the signal is handled.
-// In this version, we are simply making sure the interceptor is functional.
+// overwrite it with 'signal_handler_interceptor()/signal_action_interceptor()'
+// in order to execute custom before and after running the actual signal
+// handler (to switch to the sigalt_unsafe_stack and back). The interception is
+// only done for signal handlers that actually use the sigaltstack.
+// The code here, is largely inspired by the way MSan does intercept signal
+// handlers in compiler-rt/lib/msan/msan_interceptors.cpp.
// sigaction is required to be async-signal-safe.
INTERCEPTOR(int, sigaction, int sig, const struct sigaction* act,
struct sigaction* oldact) {
- return REAL(sigaction)(sig, act, oldact);
+ if (!act || !sigactions)
----------------
jakos-sec wrote:
Currently to make absolute certain that it was initialized with
`EnsureInterceptorsInitialized()` was called but without it `REAL(sigaction)`
would fail anyways. So I could also remove it, it was more to be extra safe.
https://github.com/llvm/llvm-project/pull/196970
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits