lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251218090656.10278-1-dannyshih@synology.com>
Date: Thu, 18 Dec 2025 17:06:56 +0800
From: dannyshih <dannyshih@...ology.com>
To: song@...nel.org,
	yukuai@...as.com
Cc: linux-raid@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	dannyshih@...ology.com
Subject: [PATCH] md: suspend array while updating raid1 raid_disks via sysfs

From: FengWei Shih <dannyshih@...ology.com>

When an I/O error occurs, the corresponding r1bio might be queued during
raid1_reshape() and not released. Leads to r1bio release with wrong
raid_disks.

* raid1_reshape() calls freeze_array(), which only waits for r1bios be
  queued or released.

Since only normal I/O might be queued while an I/O error occurs, suspending
the array avoids this issue.

Signed-off-by: FengWei Shih <dannyshih@...ology.com>
---
 drivers/md/md.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index e5922a682953..6424652bce6e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4402,12 +4402,13 @@ raid_disks_store(struct mddev *mddev, const char *buf, size_t len)
 {
 	unsigned int n;
 	int err;
+	bool need_suspend = (mddev->pers && mddev->level == 1);
 
 	err = kstrtouint(buf, 10, &n);
 	if (err < 0)
 		return err;
 
-	err = mddev_lock(mddev);
+	err = need_suspend ? mddev_suspend_and_lock(mddev) : mddev_lock(mddev);
 	if (err)
 		return err;
 	if (mddev->pers)
@@ -4432,7 +4433,7 @@ raid_disks_store(struct mddev *mddev, const char *buf, size_t len)
 	} else
 		mddev->raid_disks = n;
 out_unlock:
-	mddev_unlock(mddev);
+	need_suspend ? mddev_unlock_and_resume(mddev) : mddev_unlock(mddev);
 	return err ? err : len;
 }
 static struct md_sysfs_entry md_raid_disks =
-- 
2.17.1


Disclaimer: The contents of this e-mail message and any attachments are confidential and are intended solely for addressee. The information may also be legally privileged. This transmission is sent in trust, for the sole purpose of delivery to the intended recipient. If you have received this transmission in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by reply e-mail or phone and delete this message and its attachments, if any.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ