File 0001-Avoid-crash-on-restart-in-imrelp-SIGTTIN-handler.patch of Package rsyslog.31905
From d77cb3ed8a5b40a40e10b570b584339155c256c9 Mon Sep 17 00:00:00 2001
From: Ali Abdallah <ali.abdallah@suse.com>
Date: Thu, 31 Aug 2023 09:20:17 +0200
Subject: [PATCH] Avoid crash on restart in imrelp SIGTTIN handler
While existing, if at specific time rsyslog receives a SIGTTIN, it
crashes due to 2 issues.
1. debug.unloadModules="off" a double free of pRelpEngine
2. debug.unloadModules="on" it crashes because the signal handler has
been unmapped from memory.
This patch covers both issues and fixes #5219.
---
plugins/imrelp/imrelp.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/plugins/imrelp/imrelp.c b/plugins/imrelp/imrelp.c
index 5d7d16a48..4f9295c8d 100644
--- a/plugins/imrelp/imrelp.c
+++ b/plugins/imrelp/imrelp.c
@@ -839,7 +839,7 @@ static void
doSIGTTIN(int __attribute__((unused)) sig)
{
const int bTerminate = ATOMIC_FETCH_32BIT(&bTerminateInputs, &mutTerminateInputs);
- if(bTerminate) {
+ if(bTerminate && (pRelpEngine != NULL)) {
relpEngineSetStop(pRelpEngine);
}
}
@@ -882,6 +882,12 @@ ENDafterRun
BEGINmodExit
CODESTARTmodExit
+ struct sigaction newAct;
+ memset(&newAct, 0, sizeof (newAct));
+ sigemptyset(&newAct.sa_mask);
+ newAct.sa_handler = SIG_IGN;
+ sigaction(SIGTTIN, &newAct, NULL);
+
if(pRelpEngine != NULL)
iRet = relpEngineDestruct(&pRelpEngine);
--
2.42.0