From 057ee283d34b01ffc4995a9e586fbda4ca84862c Mon Sep 17 00:00:00 2001 From: Zhiqiang Liu Date: Mon, 14 Nov 2022 15:40:10 +0800 Subject: [PATCH] mdadm: backport one patch to fix segfault problem in monitor.c fix issue:https://gitee.com/src-openeuler/mdadm/issues/I611EL backport upstream bugfix patch to fix segfault problem Signed-off-by: Zhiqiang Liu (cherry picked from commit fc24ae7689de308e008801777e1909c8c9b398a4) --- ...gfault-when-calling-NULL-get_bad_blo.patch | 35 +++++++++++++++++++ mdadm.spec | 6 +++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 0003-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch diff --git a/0003-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch b/0003-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch new file mode 100644 index 0000000..dd381e2 --- /dev/null +++ b/0003-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch @@ -0,0 +1,35 @@ +From 9ae62977b51dab0f4bb46b1c8ea5ebd1705b2f4d Mon Sep 17 00:00:00 2001 +From: Logan Gunthorpe +Date: Wed, 22 Jun 2022 14:25:10 -0600 +Subject: [PATCH] monitor: Avoid segfault when calling NULL get_bad_blocks + +Not all struct superswitch implement a get_bad_blocks() function, +yet mdmon seems to call it without checking for NULL and thus +occasionally segfaults in the test 10ddf-geometry. + +Fix this by checking for NULL before calling it. + +Signed-off-by: Logan Gunthorpe +Acked-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +--- + monitor.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/monitor.c b/monitor.c +index b877e595..820a93d0 100644 +--- a/monitor.c ++++ b/monitor.c +@@ -311,6 +311,9 @@ static int check_for_cleared_bb(struct active_array *a, struct mdinfo *mdi) + struct md_bb *bb; + int i; + ++ if (!ss->get_bad_blocks) ++ return -1; ++ + /* + * Get a list of bad blocks for an array, then read list of + * acknowledged bad blocks from kernel and compare it against metadata +-- +2.33.0 + diff --git a/mdadm.spec b/mdadm.spec index 3234e54..657b400 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -1,6 +1,6 @@ Name: mdadm Version: 4.2 -Release: 1 +Release: 2 Summary: The software RAID arrays user manage tools License: GPLv2+ URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/ @@ -12,6 +12,7 @@ Source3: mdadm.conf Patch1: 0001-mdadm-remove-Werror-to-fix-Werror-address-of-packed-.patch Patch2: 0002-mdadm-Fix-mdadm-r-remove-option-regresision.patch +Patch3: 0003-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch BuildRequires: systemd gcc binutils libudev-devel Requires(post): systemd coreutils @@ -77,6 +78,9 @@ install -d -m 710 %{buildroot}/var/run/mdadm/ %{_mandir}/man*/* %changelog +* Mon Nov 14 2022 Zhiqiang Liu - 4.2-2 +- backport upstream bugfix patch to fix segfault problem + * Mon Oct 17 2022 wuguanghao - 4.2-1 - upgrade version to 4.2 -- Gitee