diff --git a/backport-rasdaemon-Fix-for-a-memory-out-of-bounds-issue-and-o.patch b/backport-rasdaemon-Fix-for-a-memory-out-of-bounds-issue-and-o.patch new file mode 100644 index 0000000000000000000000000000000000000000..47ae7386d1dbe32722cff64d49a8abde09c8c5b7 --- /dev/null +++ b/backport-rasdaemon-Fix-for-a-memory-out-of-bounds-issue-and-o.patch @@ -0,0 +1,91 @@ +From bf97218d9c51ded0eefe6550f12a484b760e3719 Mon Sep 17 00:00:00 2001 +From: Shiju Jose +Date: Thu, 28 Apr 2022 22:59:04 +0100 +Subject: [PATCH] rasdaemon: Fix for a memory out-of-bounds issue and optimized + code to remove duplicate function. + +Fixed a memory out-of-bounds issue with string pointers and +optimized code structure to remove duplicate function. + +Signed-off-by: Lei Feng +Signed-off-by: Shiju Jose +Signed-off-by: Mauro Carvalho Chehab +--- + non-standard-hisi_hip08.c | 6 +++--- + non-standard-hisilicon.c | 2 +- + ras-non-standard-handler.c | 16 +--------------- + 3 files changed, 5 insertions(+), 19 deletions(-) + +diff --git a/non-standard-hisi_hip08.c b/non-standard-hisi_hip08.c +index 9092183..4ef47ea 100644 +--- a/non-standard-hisi_hip08.c ++++ b/non-standard-hisi_hip08.c +@@ -1014,15 +1014,15 @@ static int decode_hip08_pcie_local_error(struct ras_events *ras, + + static struct ras_ns_ev_decoder hip08_ns_ev_decoder[] = { + { +- .sec_type = "1f8161e155d641e6bd107afd1dc5f7c5", ++ .sec_type = "1f8161e1-55d6-41e6-bd10-7afd1dc5f7c5", + .decode = decode_hip08_oem_type1_error, + }, + { +- .sec_type = "45534ea6ce2341158535e07ab3aef91d", ++ .sec_type = "45534ea6-ce23-4115-8535-e07ab3aef91d", + .decode = decode_hip08_oem_type2_error, + }, + { +- .sec_type = "b2889fc9e7d74f9da867af42e98be772", ++ .sec_type = "b2889fc9-e7d7-4f9d-a867-af42e98be772", + .decode = decode_hip08_pcie_local_error, + }, + }; +diff --git a/non-standard-hisilicon.c b/non-standard-hisilicon.c +index d1e1774..6ee9271 100644 +--- a/non-standard-hisilicon.c ++++ b/non-standard-hisilicon.c +@@ -387,7 +387,7 @@ static int decode_hisi_common_section(struct ras_events *ras, + + static struct ras_ns_ev_decoder hisi_section_ns_ev_decoder[] = { + { +- .sec_type = "c8b328a899174af69a132e08ab2e7586", ++ .sec_type = "c8b328a8-9917-4af6-9a13-2e08ab2e7586", + .decode = decode_hisi_common_section, + }, + }; +diff --git a/ras-non-standard-handler.c b/ras-non-standard-handler.c +index 6d5a6f8..6932e58 100644 +--- a/ras-non-standard-handler.c ++++ b/ras-non-standard-handler.c +@@ -52,20 +52,6 @@ static char *uuid_le(const char *uu) + return uuid; + } + +-static int uuid_le_cmp(const char *sec_type, const char *uuid2) +-{ +- static char uuid1[32]; +- char *p = uuid1; +- int i; +- static const unsigned char le[16] = { +- 3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15}; +- +- for (i = 0; i < 16; i++) +- p += sprintf(p, "%.2x", (unsigned char) sec_type[le[i]]); +- *p = 0; +- return strncmp(uuid1, uuid2, 32); +-} +- + int register_ns_ev_decoder(struct ras_ns_ev_decoder *ns_ev_decoder) + { + struct ras_ns_ev_decoder *list; +@@ -96,7 +82,7 @@ static int find_ns_ev_decoder(const char *sec_type, struct ras_ns_ev_decoder **p + + ns_ev_decoder = ras_ns_ev_dec_list; + while (ns_ev_decoder) { +- if (uuid_le_cmp(sec_type, ns_ev_decoder->sec_type) == 0) { ++ if (strcmp(uuid_le(sec_type), ns_ev_decoder->sec_type) == 0) { + *p_ns_ev_dec = ns_ev_decoder; + match = 1; + break; +-- +2.27.0 + diff --git a/backport-rasdaemon-ras-mc-ctl-Fix-script-to-parse-dimm-sizes.patch b/backport-rasdaemon-ras-mc-ctl-Fix-script-to-parse-dimm-sizes.patch new file mode 100644 index 0000000000000000000000000000000000000000..d9331e5ef3b0227ec50768c30a1eec8db7b93593 --- /dev/null +++ b/backport-rasdaemon-ras-mc-ctl-Fix-script-to-parse-dimm-sizes.patch @@ -0,0 +1,56 @@ +From 9415b7449c70f5ea4a0209ddb89c2f5f392d3b4b Mon Sep 17 00:00:00 2001 +From: Muralidhara M K +Date: Tue, 27 Jul 2021 06:36:45 -0500 +Subject: [PATCH] rasdaemon: ras-mc-ctl: Fix script to parse dimm sizes + +Removes trailing spaces at the end of a line from +file location and fixes --layout option to parse dimm nodes +to get the size of each dimm from ras-mc-ctl. + +Issue is reported https://github.com/mchehab/rasdaemon/issues/43 +Where '> ras-mc-ctl --layout' reports all 0s + +With this change the layout option prints the correct dimm sizes +> sudo ras-mc-ctl --layout + +-----------------------------------------------+ + | mc0 | + | csrow0 | csrow1 | csrow2 | csrow3 | +----------+-----------------------------------------------+ +... +channel7: | 16384 MB | 0 MB | 0 MB | 0 MB | +channel6: | 16384 MB | 0 MB | 0 MB | 0 MB | +... +----------+-----------------------------------------------+ + +Signed-off-by: Muralidhara M K +Signed-off-by: Naveen Krishna Chatradhi +Cc: Yazen Ghannam +Signed-off-by: Mauro Carvalho Chehab +Link: https://lkml.kernel.org/r/20210810183855.129076-1-nchatrad@amd.com/ +--- + util/ras-mc-ctl.in | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in +index 1e3aeb7..b22dd60 100755 +--- a/util/ras-mc-ctl.in ++++ b/util/ras-mc-ctl.in +@@ -246,6 +246,7 @@ sub parse_dimm_nodes + if (($file =~ /max_location$/)) { + open IN, $file; + my $location = ; ++ $location =~ s/\s+$//; + close IN; + my @temp = split(/ /, $location); + +@@ -288,6 +289,7 @@ sub parse_dimm_nodes + + open IN, $file; + my $location = ; ++ $location =~ s/\s+$//; + close IN; + + my @pos; +-- +2.27.0 + diff --git a/backport-rasdaemon-ras-memory-failure-handler-handle-localtim.patch b/backport-rasdaemon-ras-memory-failure-handler-handle-localtim.patch new file mode 100644 index 0000000000000000000000000000000000000000..ed749fedac8585c6fa45a91f55c534ffdaa08534 --- /dev/null +++ b/backport-rasdaemon-ras-memory-failure-handler-handle-localtim.patch @@ -0,0 +1,34 @@ +From ce33041e0abfa20054ff5d6874ffbd1ab592558d Mon Sep 17 00:00:00 2001 +From: Aristeu Rozanski +Date: Thu, 19 Jan 2023 08:45:57 -0500 +Subject: [PATCH] rasdaemon: ras-memory-failure-handler: handle localtime() + failure correctly + +We could just have an empty string but keeping the format could prevent +issues if someone is actually parsing this. +Found with covscan. + +v2: fixed the timestamp as pointed by Robert Elliott + +Signed-off-by: Aristeu Rozanski +Signed-off-by: Mauro Carvalho Chehab +--- + ras-memory-failure-handler.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/ras-memory-failure-handler.c b/ras-memory-failure-handler.c +index 9941e68..1951456 100644 +--- a/ras-memory-failure-handler.c ++++ b/ras-memory-failure-handler.c +@@ -148,6 +148,8 @@ int ras_memory_failure_event_handler(struct trace_seq *s, + if (tm) + strftime(ev.timestamp, sizeof(ev.timestamp), + "%Y-%m-%d %H:%M:%S %z", tm); ++ else ++ strncpy(ev.timestamp, "1970-01-01 00:00:00 +0000", sizeof(ev.timestamp)); + trace_seq_printf(s, "%s ", ev.timestamp); + + if (pevent_get_field_val(s, event, "pfn", record, &val, 1) < 0) +-- +2.27.0 + diff --git a/backport-rasdaemon-ras-report-fix-possible-but-unlikely-file-.patch b/backport-rasdaemon-ras-report-fix-possible-but-unlikely-file-.patch new file mode 100644 index 0000000000000000000000000000000000000000..4c7953cda6346928af1674bd59c795a798f91800 --- /dev/null +++ b/backport-rasdaemon-ras-report-fix-possible-but-unlikely-file-.patch @@ -0,0 +1,93 @@ +From 899fcc2cf21c86b5462c8f4441cd9c92b3d75f7d Mon Sep 17 00:00:00 2001 +From: Aristeu Rozanski +Date: Thu, 19 Jan 2023 08:45:57 -0500 +Subject: [PATCH] rasdaemon: ras-report: fix possible but unlikely file + descriptor leak + +Found with covscan. + +Signed-off-by: Aristeu Rozanski +Signed-off-by: Mauro Carvalho Chehab +--- + ras-report.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/ras-report.c b/ras-report.c +index ea3a9b6..62d5eb7 100644 +--- a/ras-report.c ++++ b/ras-report.c +@@ -434,7 +434,7 @@ int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev){ + + mc_fail: + +- if(sockfd > 0){ ++ if(sockfd >= 0){ + close(sockfd); + } + +@@ -484,7 +484,7 @@ int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev){ + + aer_fail: + +- if(sockfd > 0){ ++ if(sockfd >= 0){ + close(sockfd); + } + +@@ -533,7 +533,7 @@ int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standar + + non_standard_fail: + +- if(sockfd > 0){ ++ if(sockfd >= 0){ + close(sockfd); + } + +@@ -578,7 +578,7 @@ int ras_report_arm_event(struct ras_events *ras, struct ras_arm_event *ev){ + + arm_fail: + +- if(sockfd > 0){ ++ if(sockfd >= 0){ + close(sockfd); + } + +@@ -624,7 +624,7 @@ int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev){ + + mce_fail: + +- if(sockfd > 0){ ++ if(sockfd >= 0){ + close(sockfd); + } + +@@ -674,7 +674,7 @@ int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev){ + + devlink_fail: + +- if(sockfd > 0){ ++ if(sockfd >= 0){ + close(sockfd); + } + +@@ -723,7 +723,7 @@ int ras_report_diskerror_event(struct ras_events *ras, struct diskerror_event *e + done = 1; + + diskerror_fail: +- if(sockfd > 0){ ++ if(sockfd >= 0){ + close(sockfd); + } + +@@ -768,7 +768,7 @@ int ras_report_mf_event(struct ras_events *ras, struct ras_mf_event *ev) + done = 1; + + mf_fail: +- if (sockfd > 0) ++ if (sockfd >= 0) + close(sockfd); + + if (done) +-- +2.27.0 + diff --git a/fix-global-buffer-overflow-when-using-uuid1.patch b/fix-global-buffer-overflow-when-using-uuid1.patch deleted file mode 100644 index 5cbee4efd0561de6a263af1c48b2ff56a2705dd2..0000000000000000000000000000000000000000 --- a/fix-global-buffer-overflow-when-using-uuid1.patch +++ /dev/null @@ -1,25 +0,0 @@ -From c9a83cc93283514c028eb88a6fd427d03ac72050 Mon Sep 17 00:00:00 2001 -From: xujing -Date: Sat, 22 Oct 2022 17:24:17 +0800 -Subject: [PATCH] fix global-buffer-overflow when using uuid1 - ---- - ras-non-standard-handler.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/ras-non-standard-handler.c b/ras-non-standard-handler.c -index 6d5a6f8..e711f76 100644 ---- a/ras-non-standard-handler.c -+++ b/ras-non-standard-handler.c -@@ -54,7 +54,7 @@ static char *uuid_le(const char *uu) - - static int uuid_le_cmp(const char *sec_type, const char *uuid2) - { -- static char uuid1[32]; -+ static char uuid1[33]; - char *p = uuid1; - int i; - static const unsigned char le[16] = { --- -2.27.0 - diff --git a/rasdaemon.spec b/rasdaemon.spec index ad728be4a02af841006d8df01ca37a6438ae3c86..7c89e6b62f866829f98f453ba3d6246423dad158 100644 --- a/rasdaemon.spec +++ b/rasdaemon.spec @@ -1,6 +1,6 @@ Name: rasdaemon Version: 0.6.7 -Release: 5 +Release: 6 License: GPLv2 Summary: Utility to get Platform Reliability, Availability and Serviceability (RAS) reports via the Kernel tracing events URL: https://github.com/mchehab/rasdaemon.git @@ -35,7 +35,11 @@ Patch13: 0003-rasdaemon-ras-mc-ctl-Reformat-error-info-of-the-HiSi.patch Patch14: 0004-rasdaemon-ras-mc-ctl-Add-printing-usage-if-necessary.patch Patch15: 0005-rasdaemon-ras-mc-ctl-Add-support-to-display-the-HiSi.patch Patch16: 0006-rasdaemon-ras-mc-ctl-Relocate-reading-and-display-Ku.patch -Patch17: fix-global-buffer-overflow-when-using-uuid1.patch + +Patch6000: backport-rasdaemon-ras-mc-ctl-Fix-script-to-parse-dimm-sizes.patch +Patch6001: backport-rasdaemon-Fix-for-a-memory-out-of-bounds-issue-and-o.patch +Patch6002: backport-rasdaemon-ras-memory-failure-handler-handle-localtim.patch +Patch6003: backport-rasdaemon-ras-report-fix-possible-but-unlikely-file-.patch %description The rasdaemon program is a daemon which monitors the platform @@ -81,6 +85,12 @@ rm INSTALL %{buildroot}/usr/include/*.h /usr/bin/systemctl enable rasdaemon.service >/dev/null 2>&1 || : %changelog +* Thu Mar 23 2023 renhongxun - 0.6.7-6 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:backport patches from upstream + * Sat Oct 22 2022 zhangruiafang - 0.6.7-5 - Type:bugfix - ID:NA