From bf62a36d771ad9d09e055a4cb574c1d4fbd9fca2 Mon Sep 17 00:00:00 2001 From: Ali Sabil Date: Thu, 23 May 2024 12:30:18 +0000 Subject: [PATCH 1/2] exceptor: Add SA_ONSTACK flag the POSIX backend Add the SA_ONSTACK flag to handle situations where and alternative signal stack has been configured using `sigaltstack`. In the situations where no alternative stack was configured, this behaves as if the flag has not been set. --- gum/backend-posix/gumexceptor-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gum/backend-posix/gumexceptor-posix.c b/gum/backend-posix/gumexceptor-posix.c index c330f8ab3..f8b582039 100644 --- a/gum/backend-posix/gumexceptor-posix.c +++ b/gum/backend-posix/gumexceptor-posix.c @@ -252,7 +252,7 @@ gum_exceptor_backend_attach (GumExceptorBackend * self) action.sa_sigaction = gum_exceptor_backend_on_signal; sigemptyset (&action.sa_mask); - action.sa_flags = SA_SIGINFO | SA_NODEFER; + action.sa_flags = SA_SIGINFO | SA_NODEFER | SA_ONSTACK; for (i = 0; i != G_N_ELEMENTS (handled_signals); i++) { gint sig = handled_signals[i]; From 04f3fbdfcb155d32e233a209c82e736a2283422c Mon Sep 17 00:00:00 2001 From: Ali Sabil Date: Fri, 24 May 2024 07:30:57 +0000 Subject: [PATCH 2/2] exceptor: Add SA_ONSTACK only if available Notably, QNX 6.x doesn't have this flag defined. --- gum/backend-posix/gumexceptor-posix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gum/backend-posix/gumexceptor-posix.c b/gum/backend-posix/gumexceptor-posix.c index f8b582039..31b7934df 100644 --- a/gum/backend-posix/gumexceptor-posix.c +++ b/gum/backend-posix/gumexceptor-posix.c @@ -252,7 +252,10 @@ gum_exceptor_backend_attach (GumExceptorBackend * self) action.sa_sigaction = gum_exceptor_backend_on_signal; sigemptyset (&action.sa_mask); - action.sa_flags = SA_SIGINFO | SA_NODEFER | SA_ONSTACK; + action.sa_flags = SA_SIGINFO | SA_NODEFER; +#ifdef SA_ONSTACK + action.sa_flags |= SA_ONSTACK; +#endif for (i = 0; i != G_N_ELEMENTS (handled_signals); i++) { gint sig = handled_signals[i];