mdadm: fix segfault of --monitor -r
fix segfault of --monitor -r. fix issue: https://gitee.com/src-openeuler/mdadm/issues/I5CY90 Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> (cherry picked from commit e627691fcc9b4147c16cd2645acf9d88af791b94)
This commit is contained in:
parent
2147843f14
commit
4fdc2d2ff7
39
6013-mdadm-fix-coredump-of-mdadm-monitor-r.patch
Normal file
39
6013-mdadm-fix-coredump-of-mdadm-monitor-r.patch
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
From 546047688e1c64638f462147c755b58119cabdc8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wu Guanghao <wuguanghao3@huawei.com>
|
||||||
|
Date: Mon, 16 Aug 2021 15:24:51 +0800
|
||||||
|
Subject: [PATCH] mdadm: fix coredump of mdadm --monitor -r
|
||||||
|
|
||||||
|
The --monitor -r option requires a parameter, otherwise a null pointer will be manipulated
|
||||||
|
when converting to integer data, and a coredump will appear.
|
||||||
|
|
||||||
|
Segmentation fault (core dumped)
|
||||||
|
|
||||||
|
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
|
||||||
|
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
|
||||||
|
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
||||||
|
---
|
||||||
|
ReadMe.c | 6 +++---
|
||||||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ReadMe.c b/ReadMe.c
|
||||||
|
index 978796ac..37d84625 100644
|
||||||
|
--- a/ReadMe.c
|
||||||
|
+++ b/ReadMe.c
|
||||||
|
@@ -81,11 +81,11 @@ char Version[] = "mdadm - v" VERSION " - " VERS_DATE EXTRAVERSION "\n";
|
||||||
|
* found, it is started.
|
||||||
|
*/
|
||||||
|
|
||||||
|
-char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:";
|
||||||
|
+char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:r:n:x:u:c:d:z:U:N:safRSow1tye:k";
|
||||||
|
char short_bitmap_options[]=
|
||||||
|
- "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:";
|
||||||
|
+ "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:r:n:x:u:c:d:z:U:N:sarfRSow1tye:k:";
|
||||||
|
char short_bitmap_auto_options[]=
|
||||||
|
- "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:";
|
||||||
|
+ "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:r:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:";
|
||||||
|
|
||||||
|
struct option long_options[] = {
|
||||||
|
{"manage", 0, 0, ManageOpt},
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
82
6014-mdadm-Fix-mdadm-r-remove-option-regresision.patch
Normal file
82
6014-mdadm-Fix-mdadm-r-remove-option-regresision.patch
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
From 7b94dd6398bc08ec58088c3ca93a8bcd6e4c2c04 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Logan Gunthorpe <logang@deltatee.com>
|
||||||
|
Date: Thu, 12 May 2022 10:30:55 -0600
|
||||||
|
Subject: [PATCH] mdadm: Fix mdadm -r remove option regresision
|
||||||
|
|
||||||
|
The commit noted below globally adds a parameter to the -r option but missed
|
||||||
|
the fact that -r is used for another purpose: --remove.
|
||||||
|
|
||||||
|
After that commit, a command such as:
|
||||||
|
|
||||||
|
mdadm /dev/md0 -r /dev/loop0
|
||||||
|
|
||||||
|
will do nothing seeing the device parameter will be consumed as a
|
||||||
|
argument to the -r option; thus, there will only be one device
|
||||||
|
seen one the command line, devs_found will only be 1 and nothing will
|
||||||
|
happen.
|
||||||
|
|
||||||
|
This caused the 01r5integ and 01raid6integ tests to hang indefinitely
|
||||||
|
as mdadm did not remove the failed device. With the device not removed,
|
||||||
|
it would not be readded. Then the loop waiting for the array status to
|
||||||
|
change would loop forever.
|
||||||
|
|
||||||
|
To fix this, revert the changes in the noted patch and create a new subopt
|
||||||
|
type for the monitor mode with parameters required for -r.
|
||||||
|
|
||||||
|
Fixes: 546047688e1c ("mdadm: fix coredump of mdadm --monitor -r")
|
||||||
|
Cc: Wu Guanghao <wuguanghao3@huawei.com>
|
||||||
|
Cc: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
|
||||||
|
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
|
||||||
|
---
|
||||||
|
ReadMe.c | 7 ++++---
|
||||||
|
mdadm.c | 1 +
|
||||||
|
mdadm.h | 1 +
|
||||||
|
3 files changed, 6 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ReadMe.c b/ReadMe.c
|
||||||
|
index 8f873c48..556104f7 100644
|
||||||
|
--- a/ReadMe.c
|
||||||
|
+++ b/ReadMe.c
|
||||||
|
@@ -81,11 +81,12 @@ char Version[] = "mdadm - v" VERSION " - " VERS_DATE EXTRAVERSION "\n";
|
||||||
|
* found, it is started.
|
||||||
|
*/
|
||||||
|
|
||||||
|
-char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:r:n:x:u:c:d:z:U:N:safRSow1tye:k";
|
||||||
|
+char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k";
|
||||||
|
+char short_monitor_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:r:n:x:u:c:d:z:U:N:safRSow1tye:k";
|
||||||
|
char short_bitmap_options[]=
|
||||||
|
- "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:r:n:x:u:c:d:z:U:N:sarfRSow1tye:k:";
|
||||||
|
+ "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:";
|
||||||
|
char short_bitmap_auto_options[]=
|
||||||
|
- "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:r:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:";
|
||||||
|
+ "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:";
|
||||||
|
|
||||||
|
struct option long_options[] = {
|
||||||
|
{"manage", 0, 0, ManageOpt},
|
||||||
|
diff --git a/mdadm.c b/mdadm.c
|
||||||
|
index be40686c..d0c5e6de 100644
|
||||||
|
--- a/mdadm.c
|
||||||
|
+++ b/mdadm.c
|
||||||
|
@@ -227,6 +227,7 @@ int main(int argc, char *argv[])
|
||||||
|
shortopt = short_bitmap_auto_options;
|
||||||
|
break;
|
||||||
|
case 'F': newmode = MONITOR;
|
||||||
|
+ shortopt = short_monitor_options;
|
||||||
|
break;
|
||||||
|
case 'G': newmode = GROW;
|
||||||
|
shortopt = short_bitmap_options;
|
||||||
|
diff --git a/mdadm.h b/mdadm.h
|
||||||
|
index 09915a00..559da3f6 100644
|
||||||
|
--- a/mdadm.h
|
||||||
|
+++ b/mdadm.h
|
||||||
|
@@ -419,6 +419,7 @@ enum mode {
|
||||||
|
};
|
||||||
|
|
||||||
|
extern char short_options[];
|
||||||
|
+extern char short_monitor_options[];
|
||||||
|
extern char short_bitmap_options[];
|
||||||
|
extern char short_bitmap_auto_options[];
|
||||||
|
extern struct option long_options[];
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: mdadm
|
Name: mdadm
|
||||||
Version: 4.1
|
Version: 4.1
|
||||||
Release: rc2.0.9
|
Release: rc2.0.10
|
||||||
Summary: The software RAID arrays user manage tools
|
Summary: The software RAID arrays user manage tools
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/
|
URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/
|
||||||
@ -23,6 +23,8 @@ Patch6009: 6009-mdmon-wait-for-previous-mdmon-to-exit-during-takeove.patch
|
|||||||
Patch6010: 6010-Assemble-Fix-starting-array-with-initial-reshape-che.patch
|
Patch6010: 6010-Assemble-Fix-starting-array-with-initial-reshape-che.patch
|
||||||
Patch6011: 6011-add-missing-units-to-examine.patch
|
Patch6011: 6011-add-missing-units-to-examine.patch
|
||||||
Patch6012: 6012-Create-Block-rounding-size-to-max.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
|
||||||
|
|
||||||
BuildRequires: systemd gcc binutils
|
BuildRequires: systemd gcc binutils
|
||||||
Requires(post): systemd coreutils
|
Requires(post): systemd coreutils
|
||||||
@ -85,6 +87,9 @@ install -d -m 710 %{buildroot}/var/run/mdadm/
|
|||||||
%{_mandir}/man*/*
|
%{_mandir}/man*/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Jun 27 2022 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 4.1-rc2.0.10
|
||||||
|
- fix segfault of --monitor -r
|
||||||
|
|
||||||
* Mon Mar 9 2020 hy <eulerstoragemt@huawei.com> - 4.1-rc2.0.9
|
* Mon Mar 9 2020 hy <eulerstoragemt@huawei.com> - 4.1-rc2.0.9
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user