summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2022-01-23 16:25:01 +0000
committerJeremy Harris <jgh146exb@wizmail.org>2022-01-23 16:25:01 +0000
commitdd09071d45761ca63f50e60eff5eed4f8e063a74 (patch)
treeb960c737af7926ec9fc959a07d8f662a34379f17
parent52e3ce3b132d85f702f0f611c84770244e119e0f (diff)
log more detail for SIGSEGV
-rw-r--r--src/src/exim.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/src/exim.c b/src/src/exim.c
index 42db457c0..3bda36178 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -262,12 +262,33 @@ exit(1);
***********************************************/
static void
+#ifdef SA_SIGINFO
+segv_handler(int sig, siginfo_t * info, void * uctx)
+{
+log_write(0, LOG_MAIN|LOG_PANIC, "SIGSEGV (fault address: %p)", info->si_addr);
+switch (info->si_code)
+ {
+ case SEGV_MAPERR: log_write(0, LOG_MAIN|LOG_PANIC, "SEGV_MAPERR"); break;
+ case SEGV_ACCERR: log_write(0, LOG_MAIN|LOG_PANIC, "SEGV_ACCERR"); break;
+ case SEGV_BNDERR: log_write(0, LOG_MAIN|LOG_PANIC, "SEGV_BNDERR"); break;
+ case SEGV_PKUERR: log_write(0, LOG_MAIN|LOG_PANIC, "SEGV_PKUERR"); break;
+ }
+if (US info->si_addr < US 4096)
+ log_write(0, LOG_MAIN|LOG_PANIC, "SIGSEGV (null pointer indirection)");
+else
+ log_write(0, LOG_MAIN|LOG_PANIC, "SIGSEGV (maybe attempt to write to immutable memory)");
+signal(SIGSEGV, SIG_DFL);
+kill(getpid(), sig);
+}
+
+#else
segv_handler(int sig)
{
log_write(0, LOG_MAIN|LOG_PANIC, "SIGSEGV (maybe attempt to write to immutable memory)");
signal(SIGSEGV, SIG_DFL);
kill(getpid(), sig);
}
+#endif
/*************************************************
@@ -1856,7 +1877,14 @@ descriptive text. */
process_info = store_get(PROCESS_INFO_SIZE, TRUE); /* tainted */
set_process_info("initializing");
os_restarting_signal(SIGUSR1, usr1_handler); /* exiwhat */
+#ifdef SA_SIGINFO
+ {
+ struct sigaction act = { .sa_sigaction = segv_handler, .sa_flags = SA_RESETHAND | SA_SIGINFO };
+ sigaction(SIGSEGV, &act, NULL);
+ }
+#else
signal(SIGSEGV, segv_handler); /* log faults */
+#endif
/* If running in a dockerized environment, the TERM signal is only
delegated to the PID 1 if we request it by setting an signal handler */