- Fixes for mdmon to ensure it run at the right time in the fight mount namespace. This fixes various problems with IMSM raid arrays in 15-SP4 (bsc#1205493, bsc#1205830) - mdmon: fix segfault 0052-mdmon-fix-segfault.patch - util: remove obsolete code from get_md_name 0053-util-remove-obsolete-code-from-get_md_name.patch - mdmon: don't test both 'all' and 'container_name'. 0054-mdmon-don-t-test-both-all-and-container_name.patch - mdmon: change systemd unit file to use --foreground 0055-mdmon-change-systemd-unit-file-to-use-foreground.patch - mdmon: Remove need for KillMode=none 0056-mdmon-Remove-need-for-KillMode-none.patch - mdmon: Improve switchroot interactions. 0057-mdmon-Improve-switchroot-interactions.patch - mdopen: always try create_named_array() 0058-mdopen-always-try-create_named_array.patch - Improvements for IMSM_NO_PLATFORM testing 0059-Improvements-for-IMSM_NO_PLATFORM-testing.patch OBS-URL: https://build.opensuse.org/request/show/1082557 OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=223
88 lines
2.3 KiB
Diff
88 lines
2.3 KiB
Diff
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] 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>
|
|
Signed-off-by: Coly Li <colyli@suse.de>
|
|
---
|
|
Makefile | 2 +-
|
|
mdmon.c | 26 ++++++++++++--------------
|
|
2 files changed, 13 insertions(+), 15 deletions(-)
|
|
|
|
diff --git a/Makefile b/Makefile
|
|
index ec1f99e..5eac1a4 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 e9d035e..ecf52dc 100644
|
|
--- a/mdmon.c
|
|
+++ b/mdmon.c
|
|
@@ -363,14 +363,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)
|
|
@@ -402,21 +402,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.35.3
|
|
|