From 01f2f58df4ea48f3ee4ca8143d9bcbaa4cb81e94 Mon Sep 17 00:00:00 2001 From: zhangyaqi Date: Wed, 5 Jun 2024 15:18:42 +0800 Subject: [PATCH] Fix null pointer for incremental in mdadm --- ...ull-pointer-for-incremental-in-mdadm.patch | 44 +++++++++++++++++++ mdadm.spec | 6 ++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 0017-Fix-null-pointer-for-incremental-in-mdadm.patch diff --git a/0017-Fix-null-pointer-for-incremental-in-mdadm.patch b/0017-Fix-null-pointer-for-incremental-in-mdadm.patch new file mode 100644 index 0000000..137579d --- /dev/null +++ b/0017-Fix-null-pointer-for-incremental-in-mdadm.patch @@ -0,0 +1,44 @@ +From 890212d6800646153210ac264ce73035cc7dd5cc Mon Sep 17 00:00:00 2001 +From: miaoguanqin +Date: Tue, 4 Apr 2023 19:31:24 +0800 +Subject: Fix null pointer for incremental in mdadm +Reference:https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/patch/?id=890212d6800646153210ac264ce73035cc7dd5cc + +when we excute mdadm --assemble, udev-md-raid-assembly.rules is triggered. +Then we stop array, we found an coredump for mdadm --incremental.func +stack are as follows: + +#0 enough (level=10, raid_disks=4, layout=258, clean=1, + avail=avail@entry=0x0) at util.c:555 +#1 0x0000562170c26965 in Incremental (devlist=, + c=, st=0x5621729b6dc0) at Incremental.c:514 +#2 0x0000562170bfb6ff in main (argc=, + argv=) at mdadm.c:1762 + +func enough() use array avail,avail allocate space in func count_active, +it may not alloc space, causing a coredump.We fix this coredump. + +Signed-off-by: Guanqin Miao +Signed-off-by: lixiaokeng +Signed-off-by: Jes Sorensen +--- + Incremental.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/Incremental.c b/Incremental.c +index a57fc32..01ba450 100644 +--- a/Incremental.c ++++ b/Incremental.c +@@ -507,6 +507,9 @@ int Incremental(struct mddev_dev *devlist, struct context *c, + GET_OFFSET | GET_SIZE)); + active_disks = count_active(st, sra, mdfd, &avail, &info); + ++ if (!avail) ++ goto out_unlock; ++ + journal_device_missing = (info.journal_device_required) && (info.journal_clean == 0); + + if (info.consistency_policy == CONSISTENCY_POLICY_PPL) +-- +2.27.0 + diff --git a/mdadm.spec b/mdadm.spec index 4541755..689966d 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -1,6 +1,6 @@ Name: mdadm Version: 4.2 -Release: 13 +Release: 14 Summary: The software RAID arrays user manage tools License: GPLv2+ URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/ @@ -26,6 +26,7 @@ Patch13: 0013-incremental-manage-do-not-verify-if-remove-is-safe.patch Patch14: 0014-Fix-race-of-mdadm-add-and-mdadm-incremental.patch Patch15: 0015-mdadm-Fix-double-free.patch Patch16: 0016-Mdmonitor-Fix-segfault.patch +Patch17: 0017-Fix-null-pointer-for-incremental-in-mdadm.patch BuildRequires: systemd gcc binutils libudev-devel @@ -92,6 +93,9 @@ install -d -m 710 %{buildroot}/var/run/mdadm/ %{_mandir}/man*/* %changelog +* Wed Jun 5 2024 zhangyaqi - 4.2-14 +- Fix null pointer for incremental in mdadm + * Wed May 8 2024 Deyuan Fan - 4.2-13 - Mdmonitor: Fix segfault -- Gitee