imjournal: Fix ASAN memeory errors
Update the patch and fix the ASAN meemory error. Needed to initilize the
variable to NULL to prevent invalid memory address.
- https://github.com/rsyslog/rsyslog/pull/5471
Google-Bug-Id: 373965756
Fusion-Link: fusion2 N/A
Tested: Rsyslog runs fine with no functionlity differences.
Change-Id: I917e549d5b5bfb0de03bcfeae13f07905be0b909
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/recipes-extended/rsyslog/rsyslog/0001-imjournal-Support-input-module.patch b/recipes-extended/rsyslog/rsyslog/0001-imjournal-Support-input-module.patch
index 56ccbda..fb2fc32 100644
--- a/recipes-extended/rsyslog/rsyslog/0001-imjournal-Support-input-module.patch
+++ b/recipes-extended/rsyslog/rsyslog/0001-imjournal-Support-input-module.patch
@@ -1,7 +1,7 @@
-From 5e4e9d5d608ca9597fac02c772e818244c663fbb Mon Sep 17 00:00:00 2001
+From 7cc304301f689426b70f92ebd37ef26303f1f477 Mon Sep 17 00:00:00 2001
From: Willy Tu <wltu@google.com>
Date: Tue, 7 Mar 2023 12:49:12 -0800
-Subject: [PATCH] imjournal: Support input module
+Subject: [PATCH 1/3] imjournal: Support input module
Allow us to bind the imjournal input to an output module. The enable us
to block journal reading if the output module is faiiling target by the
@@ -1176,5 +1176,5 @@
/* we need to create the inputName property (only once during our lifetime) */
CHKiRet(prop.CreateStringProp(&pInputName, UCHAR_CONSTANT("imjournal"), sizeof("imjournal") - 1));
--
-2.43.0.rc2.451.g8631bc7472-goog
+2.47.0.rc1.288.g06298d1525-goog
diff --git a/recipes-extended/rsyslog/rsyslog/0002-imjournal-Fix-invalid-memory-READ-issue.patch b/recipes-extended/rsyslog/rsyslog/0002-imjournal-Fix-invalid-memory-READ-issue.patch
new file mode 100644
index 0000000..de3da75
--- /dev/null
+++ b/recipes-extended/rsyslog/rsyslog/0002-imjournal-Fix-invalid-memory-READ-issue.patch
@@ -0,0 +1,49 @@
+From 7dc14430d5a853c9296215f6042d6b21f80ff810 Mon Sep 17 00:00:00 2001
+From: Willy Tu <wltu@google.com>
+Date: Wed, 16 Oct 2024 23:02:05 +0000
+Subject: [PATCH 2/3] imjournal: Fix invalid memory READ issue
+
+Initlize inst->stateFile to NULL to prevent it from having invalid
+address.
+
+When running with ASAN on it will hit the following error.
+```
+$ /tmp/rsyslogd -n -iNONE
+AddressSanitizer:DEADLYSIGNAL
+=================================================================
+==8588==ERROR: AddressSanitizer: SEGV on unknown address 0xbebebeae (pc 0xa6984f8c bp 0xaefb70cc sp 0xaefb6c68 T0)
+==8588==The signal is caused by a READ memory access.
+ #0 0xa6984f8c (/usr/lib/libasan.so.8+0x20f8c) (BuildId: ee0b8a590de2b6d96c2138cdebb2499a90e6a07a)
+ #1 0xa6a3b728 (/usr/lib/libasan.so.8+0xd7728) (BuildId: ee0b8a590de2b6d96c2138cdebb2499a90e6a07a)
+ #2 0xa617c054 (/usr/lib/rsyslog/imjournal.so+0x6054) (BuildId: ca1c5d369cffa79029a75c06e0e18d62368c9bca)
+ #3 0x4ff0e4 (/tmp/rsyslogd+0xa20e4) (BuildId: 14bec8475dcbac6b4061007eb0f4e4e3bab3aa38)
+ #4 0x48f8bc (/tmp/rsyslogd+0x328bc) (BuildId: 14bec8475dcbac6b4061007eb0f4e4e3bab3aa38)
+ #5 0x488330 in main (/tmp/rsyslogd+0x2b330) (BuildId: 14bec8475dcbac6b4061007eb0f4e4e3bab3aa38)
+ #6 0xa66a54ac (/usr/lib/libc.so.6+0x1f4ac) (BuildId: c9c455a6e5b9355d2e08c2695ea6374f1ecc583c)
+ #7 0xa66a5598 in __libc_start_main (/usr/lib/libc.so.6+0x1f598) (BuildId: c9c455a6e5b9355d2e08c2695ea6374f1ecc583c)
+
+AddressSanitizer can not provide additional info.
+SUMMARY: AddressSanitizer: SEGV (/usr/lib/libasan.so.8+0x20f8c) (BuildId: ee0b8a590de2b6d96c2138cdebb2499a90e6a07a)
+==8588==ABORTING
+```
+
+Signed-off-by: Willy Tu <wltu@google.com>
+---
+ plugins/imjournal/imjournal.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c
+index d059edbd4..21f36ffb1 100644
+--- a/plugins/imjournal/imjournal.c
++++ b/plugins/imjournal/imjournal.c
+@@ -1369,6 +1369,7 @@ createInstance(instanceConf_t **const pinst)
+ inst->next = NULL;
+ inst->pBindRuleset = NULL;
+ inst->pszBindRuleset = NULL;
++ inst->stateFile = NULL;
+
+ /* node created, let's add to config */
+ if(loadModConf->tail == NULL) {
+--
+2.47.0.rc1.288.g06298d1525-goog
+
diff --git a/recipes-extended/rsyslog/rsyslog_%.bbappend b/recipes-extended/rsyslog/rsyslog_%.bbappend
index 89739dc..a863ce2 100644
--- a/recipes-extended/rsyslog/rsyslog_%.bbappend
+++ b/recipes-extended/rsyslog/rsyslog_%.bbappend
@@ -2,4 +2,5 @@
SRC_URI:append:gbmc = " \
file://0001-imjournal-Support-input-module.patch \
+ file://0002-imjournal-Fix-invalid-memory-READ-issue.patch \
"