diff --git a/SOURCES/008125849f94a5c7d8ccbd56ed1156f49169d273.patch b/SOURCES/008125849f94a5c7d8ccbd56ed1156f49169d273.patch new file mode 100644 index 0000000..d04d5fe --- /dev/null +++ b/SOURCES/008125849f94a5c7d8ccbd56ed1156f49169d273.patch @@ -0,0 +1,85 @@ +commit 008125849f94a5c7d8ccbd56ed1156f49169d273 +Author: Shiju Jose +Date: Wed Oct 16 17:33:55 2019 +0100 + + rasdaemon: fix cleanup issues in ras-events.c:read_ras_event_all_cpus() + + This patch fix memory leaks and close the open files if the + open_trace() or read(fds[i].fd, page, pdata[i].ras->page_size) + function calls fail. + + Signed-off-by: Shiju Jose + Signed-off-by: Mauro Carvalho Chehab + +diff --git a/ras-events.c b/ras-events.c +index 3cdac19..d1773b1 100644 +--- a/ras-events.c ++++ b/ras-events.c +@@ -353,6 +353,7 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata, + struct pollfd fds[n_cpus]; + int warnonce[n_cpus]; + char pipe_raw[PATH_MAX]; ++ int legacy_kernel = 0; + #if 0 + int need_sleep = 0; + #endif +@@ -372,6 +373,9 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata, + return -ENOMEM; + } + ++ for (i = 0; i < n_cpus; i++) ++ fds[i].fd = -1; ++ + for (i = 0; i < n_cpus; i++) { + fds[i].events = POLLIN; + +@@ -382,9 +386,7 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata, + fds[i].fd = open_trace(pdata[0].ras, pipe_raw, O_RDONLY); + if (fds[i].fd < 0) { + log(TERM, LOG_ERR, "Can't open trace_pipe_raw\n"); +- kbuffer_free(kbuf); +- free(page); +- return -EINVAL; ++ goto error; + } + } + +@@ -416,7 +418,7 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata, + size = read(fds[i].fd, page, pdata[i].ras->page_size); + if (size < 0) { + log(TERM, LOG_WARNING, "read\n"); +- return -1; ++ goto error; + } else if (size > 0) { + kbuffer_load_subbuffer(kbuf, page); + +@@ -441,6 +443,7 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata, + */ + if (count_nready == n_cpus) { + /* Should only happen with legacy kernels */ ++ legacy_kernel = 1; + break; + } + #endif +@@ -449,12 +452,18 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata, + /* poll() is not supported. We need to fallback to the old way */ + log(TERM, LOG_INFO, + "Old kernel detected. Stop listening and fall back to pthread way.\n"); ++error: + kbuffer_free(kbuf); + free(page); +- for (i = 0; i < n_cpus; i++) +- close(fds[i].fd); ++ for (i = 0; i < n_cpus; i++) { ++ if (fds[i].fd > 0) ++ close(fds[i].fd); ++ } + +- return -255; ++ if (legacy_kernel) ++ return -255; ++ else ++ return -1; + } + + static int read_ras_event(int fd, diff --git a/SOURCES/3dca35f17effa102b7140d5554401ef2292425b7.patch b/SOURCES/3dca35f17effa102b7140d5554401ef2292425b7.patch new file mode 100644 index 0000000..3c0802f --- /dev/null +++ b/SOURCES/3dca35f17effa102b7140d5554401ef2292425b7.patch @@ -0,0 +1,144 @@ +commit 3dca35f17effa102b7140d5554401ef2292425b7 +Author: Aristeu Rozanski +Date: Tue Jan 7 14:49:19 2020 -0500 + + rasdaemon: fix error handling in ras_mc_event_opendb() + + Found with covscan that the return value from ras_mc_prepare_stmt() and from + ras_mc_event_opendb() itself aren't checked. + + Signed-off-by: Aristeu Rozanski + Signed-off-by: Mauro Carvalho Chehab + +--- + ras-events.c | 17 +++++++++++++---- + ras-record.c | 42 +++++++++++++++++++++++++++++++----------- + 2 files changed, 44 insertions(+), 15 deletions(-) + +--- rasdaemon-0.4.1.orig/ras-events.c 2020-03-18 15:58:10.477721778 -0400 ++++ rasdaemon-0.4.1/ras-events.c 2020-03-18 15:59:05.398236266 -0400 +@@ -348,8 +348,10 @@ if (fds[i].fd < 0) { + } + + log(TERM, LOG_INFO, "Listening to events for cpus 0 to %d\n", n_cpus - 1); +- if (pdata[0].ras->record_events) +- ras_mc_event_opendb(pdata[0].cpu, pdata[0].ras); ++ if (pdata[0].ras->record_events) { ++ if (ras_mc_event_opendb(pdata[0].cpu, pdata[0].ras)) ++ goto error; ++ } + + do { + ready = poll(fds, n_cpus, -1); +@@ -485,8 +487,15 @@ if (fd < 0) { + } + + log(TERM, LOG_INFO, "Listening to events on cpu %d\n", pdata->cpu); +- if (pdata->ras->record_events) +- ras_mc_event_opendb(pdata->cpu, pdata->ras); ++ if (pdata->ras->record_events) { ++ if (ras_mc_event_opendb(pdata->cpu, pdata->ras)) { ++ log(TERM, LOG_ERR, "Can't open database\n"); ++ close(fd); ++ kbuffer_free(kbuf); ++ free(page); ++ return 0; ++ } ++ } + + read_ras_event(fd, pdata, kbuf, page); + +--- rasdaemon-0.4.1.orig/ras-record.c 2020-03-18 15:58:10.478721769 -0400 ++++ rasdaemon-0.4.1/ras-record.c 2020-03-18 16:02:31.382415310 -0400 +@@ -506,8 +506,7 @@ int ras_mc_event_opendb(unsigned cpu, st + log(TERM, LOG_ERR, + "cpu %u: Failed to initialize sqlite: error = %d\n", + cpu, rc); +- free(priv); +- return -1; ++ goto error; + } + + do { +@@ -523,51 +522,72 @@ usleep(10000); + log(TERM, LOG_ERR, + "cpu %u: Failed to connect to %s: error = %d\n", + cpu, SQLITE_RAS_DB, rc); +- free(priv); +- return -1; ++ goto error; + } + priv->db = db; + + rc = ras_mc_create_table(priv, &mc_event_tab); +- if (rc == SQLITE_OK) ++ if (rc == SQLITE_OK) { + rc = ras_mc_prepare_stmt(priv, &priv->stmt_mc_event, + &mc_event_tab); ++ if (rc != SQLITE_OK) ++ goto error; ++ } + + #ifdef HAVE_AER + rc = ras_mc_create_table(priv, &aer_event_tab); +- if (rc == SQLITE_OK) ++ if (rc == SQLITE_OK) { + rc = ras_mc_prepare_stmt(priv, &priv->stmt_aer_event, + &aer_event_tab); ++ if (rc != SQLITE_OK) ++ goto error; ++ } + #endif + + #ifdef HAVE_EXTLOG + rc = ras_mc_create_table(priv, &extlog_event_tab); +- if (rc == SQLITE_OK) ++ if (rc == SQLITE_OK) { + rc = ras_mc_prepare_stmt(priv, &priv->stmt_extlog_record, + &extlog_event_tab); ++ if (rc != SQLITE_OK) ++ goto error; ++ } + #endif + + #ifdef HAVE_MCE + rc = ras_mc_create_table(priv, &mce_record_tab); +- if (rc == SQLITE_OK) ++ if (rc == SQLITE_OK) { + rc = ras_mc_prepare_stmt(priv, &priv->stmt_mce_record, + &mce_record_tab); ++ if (rc != SQLITE_OK) ++ goto error; ++ } + #endif + + #ifdef HAVE_NON_STANDARD + rc = ras_mc_create_table(priv, &non_standard_event_tab); +- if (rc == SQLITE_OK) ++ if (rc == SQLITE_OK) { + rc = ras_mc_prepare_stmt(priv, &priv->stmt_non_standard_record, + &non_standard_event_tab); ++ if (rc != SQLITE_OK) ++ goto error; ++ } + #endif + + #ifdef HAVE_ARM + rc = ras_mc_create_table(priv, &arm_event_tab); +- if (rc == SQLITE_OK) ++ if (rc == SQLITE_OK) { + rc = ras_mc_prepare_stmt(priv, &priv->stmt_arm_record, + &arm_event_tab); ++ if (rc != SQLITE_OK) ++ goto error; ++ } + #endif + +- ras->db_priv = priv; ++ ras->db_priv = priv; + return 0; ++ ++error: ++ free(priv); ++ return -1; + } diff --git a/SOURCES/9baae41e14b825b487c80a743a21bfdf6175bd19.patch b/SOURCES/9baae41e14b825b487c80a743a21bfdf6175bd19.patch new file mode 100644 index 0000000..cf9dd50 --- /dev/null +++ b/SOURCES/9baae41e14b825b487c80a743a21bfdf6175bd19.patch @@ -0,0 +1,29 @@ +commit 9baae41e14b825b487c80a743a21bfdf6175bd19 +Author: Mauro Carvalho Chehab +Date: Tue Jun 11 15:01:38 2019 -0300 + + ras-mce-handler: fix mcgstatus message print + + As warned by clang, the test there is wrong: + + ras-mce-handler.c:344:9: warning: address of array 'e->mcgstatus_msg' will always evaluate to 'true' [-Wpointer-bool-conversion] + if (e->mcgstatus_msg) + ~~ ~~~^~~~~~~~~~~~~ + + Signed-off-by: Mauro Carvalho Chehab + +--- + ras-mce-handler.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- rasdaemon-0.4.1.orig/ras-mce-handler.c 2020-01-10 10:03:09.990876004 -0500 ++++ rasdaemon-0.4.1/ras-mce-handler.c 2020-01-10 10:03:50.554469958 -0500 +@@ -334,7 +334,7 @@ #if 0 + if (e->status & MCI_STATUS_ADDRV) + trace_seq_printf(s, ", addr= %llx", (long long)e->addr); + +- if (e->mcgstatus_msg) ++ if (*e->mcgstatus_msg) + trace_seq_printf(s, ", %s", e->mcgstatus_msg); + else + trace_seq_printf(s, ", mcgstatus= %llx", diff --git a/SPECS/rasdaemon.spec b/SPECS/rasdaemon.spec index d705e65..decaae9 100644 --- a/SPECS/rasdaemon.spec +++ b/SPECS/rasdaemon.spec @@ -2,7 +2,7 @@ Name: rasdaemon Version: 0.4.1 -Release: 35%{?dist} +Release: 37%{?dist} Summary: Utility to receive RAS error tracings Group: Applications/System License: GPLv2 @@ -86,6 +86,9 @@ Patch59: 0068-rasdaemon-add-support-for-non-standard-error-decoder.patch Patch60: 0069-rasdaemon-add-support-for-ARM-events.patch Patch61: 0070-rasdaemon-ARM-fully-initialize-ras_arm_event.patch Patch62: 0071-rasdaemon-ras-mc-ctl-add-option-to-show-error-counts.patch +Patch63: 9baae41e14b825b487c80a743a21bfdf6175bd19.patch +Patch64: 008125849f94a5c7d8ccbd56ed1156f49169d273.patch +Patch65: 3dca35f17effa102b7140d5554401ef2292425b7.patch %description %{name} is a RAS (Reliability, Availability and Serviceability) logging tool. @@ -161,6 +164,9 @@ an utility for reporting current error counts from the EDAC sysfs files. %patch60 -p1 %patch61 -p1 %patch62 -p1 +%patch63 -p1 +%patch64 -p1 +%patch65 -p1 %build autoreconf -vfi @@ -189,6 +195,12 @@ rm -rf %{buildroot} %{_sysconfdir}/ras/dimm_labels.d %changelog +* Wed Mar 18 2020 Aristeu Rozanski 0.4.1-37.el7 +- rasdaemon: fix error handling in ras_mc_event_opendb [1694748] + +* Fri Jan 10 2020 Aristeu Rozanski 0.4.1-36.el7 +- ras-mce-handler: fix mcgstatus message print [1525210] + * Fri Jan 25 2019 Aristeu Rozanski 0.4.1-35.el7 - Add support to show error counts only [1573686]