diff --git a/6015-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch b/6015-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch new file mode 100644 index 0000000000000000000000000000000000000000..dd381e243ffa6335046157e1ea3f2058bd76bdaa --- /dev/null +++ b/6015-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 e7e2d86116eebaaf44cc99766e641c8de01b327f..3aabbe214bd4b69beb24f49e84965caf125d9e86 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -1,6 +1,6 @@ Name: mdadm Version: 4.1 -Release: rc2.0.10 +Release: rc2.0.11 Summary: The software RAID arrays user manage tools License: GPLv2+ URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/ @@ -25,6 +25,7 @@ Patch6011: 6011-add-missing-units-to-examine.patch Patch6012: 6012-Create-Block-rounding-size-to-max.patch Patch6013: 6013-mdadm-fix-coredump-of-mdadm-monitor-r.patch Patch6014: 6014-mdadm-Fix-mdadm-r-remove-option-regresision.patch +Patch6015: 6015-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch BuildRequires: systemd gcc binutils Requires(post): systemd coreutils @@ -87,6 +88,9 @@ install -d -m 710 %{buildroot}/var/run/mdadm/ %{_mandir}/man*/* %changelog +* Mon Nov 14 2022 Zhiqiang Liu - 4.1-rc2.0.11 +- backport upstream bugfix patch to fix segfault problem in monitor.c + * Mon Jun 27 2022 Zhiqiang Liu - 4.1-rc2.0.10 - fix segfault of --monitor -r