fix null pointer for incremental in mdadm

(cherry picked from commit a23a49cd9fad7d590861534a107d35b8ddc2ce96)
This commit is contained in:
miaoguanqin 2023-09-12 16:48:51 +08:00 committed by openeuler-sync-bot
parent 2343c40473
commit 6693c24b50
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,43 @@
From 890212d6800646153210ac264ce73035cc7dd5cc Mon Sep 17 00:00:00 2001
From: miaoguanqin <miaoguanqin@huawei.com>
Date: Tue, 4 Apr 2023 19:31:24 +0800
Subject: [PATCH] Fix null pointer for incremental in mdadm
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=<optimized out>,
c=<optimized out>, st=0x5621729b6dc0) at Incremental.c:514
#2 0x0000562170bfb6ff in main (argc=<optimized out>,
argv=<optimized out>) 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 <miaoguanqin@huawei.com>
Signed-off-by: lixiaokeng <lixiaokeng@huawei.com>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
---
Incremental.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Incremental.c b/Incremental.c
index 09b94b9f..49a71f72 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

View File

@ -1,6 +1,6 @@
Name: mdadm
Version: 4.1
Release: rc2.0.15
Release: rc2.0.16
Summary: The software RAID arrays user manage tools
License: GPLv2+
URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/
@ -32,6 +32,7 @@ Patch6018: 6018-mdadm-block-creation-with-long-names.patch
Patch6019: 6019-mdadm-Don-t-open-md-device-for-CREATE-and-ASSEMBLE.patch
Patch6020: 6020-fix-NULL-dereference-in-super_by_fd.patch
Patch6021: 6021-Fix-memory-leak-after-mdadm-detail.patch
Patch6022: 6022-Fix-null-pointer-for-incremental-in-mdadm.patch
BuildRequires: systemd gcc binutils
Requires(post): systemd coreutils
@ -94,6 +95,9 @@ install -d -m 710 %{buildroot}/var/run/mdadm/
%{_mandir}/man*/*
%changelog
* Tue Sep 12 2023 miaoguanqin <miaoguanqin@huawei.com> - 4.1-rc2.0.16
- fix null pointer for incremental in mdadm
* Thu Sep 7 2023 miaoguanqin <miaoguanqin@huawei.com> - 4.1-rc2.0.15
- fix CVE-2023-28938 for mdadm