mdadm/0157-mdstat-fix-list-detach-issues.patch
Xiao Ni f1b7707f26 Update to latest upstream
For issue RHEL-40729, patch 0142 fixes it.
For issue RHEL-31448, patch 0125 fixes it.

Resolves: RHEL-31448,RHEL-40729,RHEL-52059

Signed-off-by: Xiao Ni <xni@redhat.com>
2024-10-19 05:22:07 -04:00

44 lines
1.2 KiB
Diff

From 4b041873ff5556882bc6f17ac3de00c72eebcc4f Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Tue, 6 Aug 2024 16:11:18 +0200
Subject: [PATCH 157/201] mdstat: fix list detach issues
Move ent = ent->next; to while. It was outside the loop so if there
are more than 2 elements and we are looking for 3rd element it causes
infinite loop..
Fix el->next zeroing. It causes segfault in mdstat_free(). Theses
issues were not visible in my testing because I had only 2 MD devices.
Fixes: 4b3644ab4ce6 ("mdstat: Rework mdstat external arrays handling")
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
mdstat.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mdstat.c b/mdstat.c
index a971a957..29e78362 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -123,13 +123,15 @@ static void mdstat_ent_list_detach_element(struct mdstat_ent **list_head, struct
ent->next = el->next;
break;
}
+
+ ent = ent->next;
}
- ent = ent->next;
}
+ /* Guard if not found or list is empty - not allowed */
assert(ent);
- ent->next = NULL;
+ el->next = NULL;
}
void free_mdstat(struct mdstat_ent *ms)
--
2.41.0