mdmon: fix segfault
(cherry picked from commit 620dff3c08f1a72b97536beb0b29e4fc7c1f9a37)
This commit is contained in:
parent
ff803b3696
commit
9189b2ce95
86
0017-mdmon-fix-segfault.patch
Normal file
86
0017-mdmon-fix-segfault.patch
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
From 9b429fc0a4ffd7028b3b336589d38e32fb9045dc Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mateusz Kusiak <mateusz.kusiak@intel.com>
|
||||||
|
Date: Mon, 2 Jan 2023 09:46:21 +0100
|
||||||
|
Subject: [PATCH 77/83] mdmon: fix segfault
|
||||||
|
|
||||||
|
Mdmon crashes if stat2devnm returns null.
|
||||||
|
Use open_mddev to check if device is mddevice and get name using
|
||||||
|
fd2devnm.
|
||||||
|
Refactor container name handling.
|
||||||
|
|
||||||
|
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
|
||||||
|
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
|
||||||
|
---
|
||||||
|
Makefile | 2 +-
|
||||||
|
mdmon.c | 26 ++++++++++++--------------
|
||||||
|
2 files changed, 13 insertions(+), 15 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/Makefile b/Makefile
|
||||||
|
index ee5bdad..4046859 100644
|
||||||
|
--- a/Makefile
|
||||||
|
+++ b/Makefile
|
||||||
|
@@ -160,7 +160,7 @@ SRCS = $(patsubst %.o,%.c,$(OBJS))
|
||||||
|
|
||||||
|
INCL = mdadm.h part.h bitmap.h
|
||||||
|
|
||||||
|
-MON_OBJS = mdmon.o monitor.o managemon.o uuid.o util.o maps.o mdstat.o sysfs.o \
|
||||||
|
+MON_OBJS = mdmon.o monitor.o managemon.o uuid.o util.o maps.o mdstat.o sysfs.o config.o mapfile.o mdopen.o\
|
||||||
|
policy.o lib.o \
|
||||||
|
Kill.o sg_io.o dlink.o ReadMe.o super-intel.o \
|
||||||
|
super-mbr.o super-gpt.o \
|
||||||
|
diff --git a/mdmon.c b/mdmon.c
|
||||||
|
index c71e62c..75d67f2 100644
|
||||||
|
--- a/mdmon.c
|
||||||
|
+++ b/mdmon.c
|
||||||
|
@@ -341,14 +341,14 @@ int main(int argc, char *argv[])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (all == 0 && container_name == NULL) {
|
||||||
|
- if (argv[optind])
|
||||||
|
- container_name = argv[optind];
|
||||||
|
+ if (argv[optind]) {
|
||||||
|
+ container_name = get_md_name(argv[optind]);
|
||||||
|
+ if (!container_name)
|
||||||
|
+ container_name = argv[optind];
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (container_name == NULL)
|
||||||
|
- usage();
|
||||||
|
-
|
||||||
|
- if (argc - optind > 1)
|
||||||
|
+ if (container_name == NULL || argc - optind > 1)
|
||||||
|
usage();
|
||||||
|
|
||||||
|
if (strcmp(container_name, "/proc/mdstat") == 0)
|
||||||
|
@@ -377,21 +377,19 @@ int main(int argc, char *argv[])
|
||||||
|
free_mdstat(mdstat);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
- } else if (strncmp(container_name, "md", 2) == 0) {
|
||||||
|
- int id = devnm2devid(container_name);
|
||||||
|
- if (id)
|
||||||
|
- devnm = container_name;
|
||||||
|
} else {
|
||||||
|
- struct stat st;
|
||||||
|
+ int mdfd = open_mddev(container_name, 1);
|
||||||
|
|
||||||
|
- if (stat(container_name, &st) == 0)
|
||||||
|
- devnm = xstrdup(stat2devnm(&st));
|
||||||
|
+ if (mdfd < 0)
|
||||||
|
+ return 1;
|
||||||
|
+ devnm = fd2devnm(mdfd);
|
||||||
|
+ close(mdfd);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!devnm) {
|
||||||
|
pr_err("%s is not a valid md device name\n",
|
||||||
|
container_name);
|
||||||
|
- exit(1);
|
||||||
|
+ return 1;
|
||||||
|
}
|
||||||
|
return mdmon(devnm, dofork && do_fork(), takeover);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: mdadm
|
Name: mdadm
|
||||||
Version: 4.2
|
Version: 4.2
|
||||||
Release: 13
|
Release: 14
|
||||||
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/
|
||||||
@ -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
|
Patch14: 0014-Fix-race-of-mdadm-add-and-mdadm-incremental.patch
|
||||||
Patch15: 0015-mdadm-Fix-double-free.patch
|
Patch15: 0015-mdadm-Fix-double-free.patch
|
||||||
Patch16: 0016-Mdmonitor-Fix-segfault.patch
|
Patch16: 0016-Mdmonitor-Fix-segfault.patch
|
||||||
|
Patch17: 0017-mdmon-fix-segfault.patch
|
||||||
|
|
||||||
BuildRequires: systemd gcc binutils libudev-devel
|
BuildRequires: systemd gcc binutils libudev-devel
|
||||||
|
|
||||||
@ -92,6 +93,9 @@ install -d -m 710 %{buildroot}/var/run/mdadm/
|
|||||||
%{_mandir}/man*/*
|
%{_mandir}/man*/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed May 15 2024 Deyuan Fan <fandeyuan@kylinos.cn> - 4.2-14
|
||||||
|
- mdmon: fix segfault
|
||||||
|
|
||||||
* Wed May 8 2024 Deyuan Fan <fandeyuan@kylinos.cn> - 4.2-13
|
* Wed May 8 2024 Deyuan Fan <fandeyuan@kylinos.cn> - 4.2-13
|
||||||
- Mdmonitor: Fix segfault
|
- Mdmonitor: Fix segfault
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user