Add 0034-libmultipath-fix-crash-in-print_foreign_topology.patch * Fixes RHEL-107436 ("Running multipath -ll on system with "enable_foreign nvme" results in segfault") Resolves: RHEL-107436
85 lines
3.0 KiB
Diff
85 lines
3.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
Date: Wed, 20 Aug 2025 18:25:03 -0400
|
|
Subject: [PATCH] libmultipath: fix crash in print_foreign_topology
|
|
|
|
print_foreign_topology() called get_paths() to get a vector of
|
|
(struct gen_path *) items and then called get_multipath_layout__(),
|
|
which expects a vector of (struct gen_multipath *) items, with the path
|
|
vector. This can easily end badly. Fix it to correctly call
|
|
get_path_layout__(), and rename width to p_width in the functions that
|
|
end up calling snprint_multipath_topology__(), which is expecting to get
|
|
passed the path field widths.
|
|
|
|
Signed-off-by: Lin Li <lilin@redhat.com>
|
|
---
|
|
libmultipath/foreign.c | 16 ++++++++--------
|
|
1 file changed, 8 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/libmultipath/foreign.c b/libmultipath/foreign.c
|
|
index d01a5ef0..b91e3898 100644
|
|
--- a/libmultipath/foreign.c
|
|
+++ b/libmultipath/foreign.c
|
|
@@ -500,7 +500,7 @@ void foreign_multipath_layout(fieldwidth_t *width)
|
|
}
|
|
|
|
static int __snprint_foreign_topology(struct strbuf *buf, int verbosity,
|
|
- const fieldwidth_t *width)
|
|
+ const fieldwidth_t *p_width)
|
|
{
|
|
struct foreign *fgn;
|
|
int i;
|
|
@@ -518,7 +518,7 @@ static int __snprint_foreign_topology(struct strbuf *buf, int verbosity,
|
|
if (vec != NULL) {
|
|
vector_foreach_slot(vec, gm, j) {
|
|
if (_snprint_multipath_topology(
|
|
- gm, buf, verbosity, width) < 0)
|
|
+ gm, buf, verbosity, p_width) < 0)
|
|
break;
|
|
}
|
|
}
|
|
@@ -530,7 +530,7 @@ static int __snprint_foreign_topology(struct strbuf *buf, int verbosity,
|
|
}
|
|
|
|
int snprint_foreign_topology(struct strbuf *buf, int verbosity,
|
|
- const fieldwidth_t *width)
|
|
+ const fieldwidth_t *p_width)
|
|
{
|
|
int rc;
|
|
|
|
@@ -540,7 +540,7 @@ int snprint_foreign_topology(struct strbuf *buf, int verbosity,
|
|
return 0;
|
|
}
|
|
pthread_cleanup_push(unlock_foreigns, NULL);
|
|
- rc = __snprint_foreign_topology(buf, verbosity, width);
|
|
+ rc = __snprint_foreign_topology(buf, verbosity, p_width);
|
|
pthread_cleanup_pop(1);
|
|
return rc;
|
|
}
|
|
@@ -550,9 +550,9 @@ void print_foreign_topology(int verbosity)
|
|
STRBUF_ON_STACK(buf);
|
|
struct foreign *fgn;
|
|
int i;
|
|
- fieldwidth_t *width __attribute__((cleanup(cleanup_ucharp))) = NULL;
|
|
+ fieldwidth_t *p_width __attribute__((cleanup(cleanup_ucharp))) = NULL;
|
|
|
|
- if ((width = alloc_path_layout()) == NULL)
|
|
+ if ((p_width = alloc_path_layout()) == NULL)
|
|
return;
|
|
rdlock_foreigns();
|
|
if (foreigns == NULL) {
|
|
@@ -566,11 +566,11 @@ void print_foreign_topology(int verbosity)
|
|
fgn->lock(fgn->context);
|
|
pthread_cleanup_push(fgn->unlock, fgn->context);
|
|
vec = fgn->get_paths(fgn->context);
|
|
- _get_multipath_layout(vec, LAYOUT_RESET_NOT, width);
|
|
+ _get_path_layout(vec, LAYOUT_RESET_NOT, p_width);
|
|
fgn->release_paths(fgn->context, vec);
|
|
pthread_cleanup_pop(1);
|
|
}
|
|
- __snprint_foreign_topology(&buf, verbosity, width);
|
|
+ __snprint_foreign_topology(&buf, verbosity, p_width);
|
|
pthread_cleanup_pop(1);
|
|
printf("%s", get_strbuf_str(&buf));
|
|
}
|