Skip to contentSkip to conversation

fix KASAN issue for dm-raid

PATCH Applied Guoqing Jiang 2 participants 4 messages Aug 17, 2022 – Aug 23, 2022 MD RAID

lore
Share & tools
lore
#0 lore raw

cover fix KASAN issue for dm-raid

Hi,

Let's try another approach to fix the KASAN issue, and to avoid cause issue for clustered raid.

Thanks,
Guoqing

Guoqing Jiang (2):
Revert "md-raid: destroy the bitmap after destroying the thread"
md: call __md_stop_writes in md_stop

 drivers/md/md.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/2 Revert "md-raid: destroy the bitmap after destroying the thread"

This reverts commit e151db8ecfb019b7da31d076130a794574c89f6f. Because it obviously breaks clustered raid as noticed by Neil though it fixed KASAN issue for dm-raid, let's revert it and fix KASAN issue in next commit.

[1]. https://lore.kernel.org/linux-raid/[email protected]/T/#m95ac225cab7409f66c295772483d091084a6d470

---
 drivers/md/md.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.c +1 -1
index afaf36b2f6ab..76acd2c72f84 100644
@@ -6238,11 +6238,11 @@ static void mddev_detach(struct mddev *mddev)
 static void __md_stop(struct mddev *mddev)
 {
 	struct md_personality *pers = mddev->pers;
+	md_bitmap_destroy(mddev);
 	mddev_detach(mddev);
 	/* Ensure ->event_work is done */
 	if (mddev->event_work.func)
 		flush_workqueue(md_misc_wq);
-	md_bitmap_destroy(mddev);
 	spin_lock(&mddev->lock);
 	mddev->pers = NULL;
 	spin_unlock(&mddev->lock);
Signature · 1 line
2.31.1
#2 lore raw

PATCH 2/2 md: call __md_stop_writes in md_stop

In reply to Guoqing Jiang

From the link [1], we can see raid1d was running even after the path raid_dtr -> md_stop -> __md_stop.

Let's stop write first in destructor to align with normal md-raid to fix the KASAN issue.

[1]. https://lore.kernel.org/linux-raid/CAPhsuW5gc4AakdGNdF8ubpezAuDLFOYUO_sfMZcec6hQFm8nhg@mail.gmail.com/T/#m7f12bf90481c02c6d2da68c64aeed4779b7df74a

---
 drivers/md/md.c | 1 +
 1 file changed, 1 insertion(+)
drivers/md/md.c +1 -0
index 76acd2c72f84..8b43cf328dc3 100644
@@ -6260,6 +6260,7 @@ void md_stop(struct mddev *mddev)
 	/* stop the array and free an attached data structures.
 	 * This is called from dm-raid
 	 */
+	__md_stop_writes(mddev);
 	__md_stop(mddev);
 	bioset_exit(&mddev->bio_set);
 	bioset_exit(&mddev->sync_set);
Signature · 1 line
2.31.1
maintainer Applied
#3 lore raw
In reply to Guoqing Jiang
Quoted 5 lines · Guoqing Jiang

Hi,

Let's try another approach to fix the KASAN issue, and to avoid cause issue for clustered raid.

Applied to md-fixes.

Thanks,
Song

Quoted 14 lines

Thanks,
Guoqing

Guoqing Jiang (2):
Revert "md-raid: destroy the bitmap after destroying the thread"
md: call __md_stop_writes in md_stop

 drivers/md/md.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--
2.31.1