Skip to contentSkip to conversation

md/raid10: Prevent data corruption after a rejected backwards reshape

PATCH Applied Chris Down 2 participants 2 messages Nov 8 – Nov 11 MD RAID

lore
Share & tools
lore

Chris Down

author
#0 lore raw

PATCH 1/1 md/raid10: Prevent data corruption after a rejected backwards reshape

A rejected backwards RAID10 reshape can leave the array using the requested geometry because raid10_start_reshape() updates conf->geo before checking whether the new geometry can hold the current array size. If the check fails, we return -EINVAL with the new geometry still in place. Subsequent I/O then uses a layout the data hasn't been moved to, so reads can return the wrong data and writes can silently corrupt the array.

To fix this, let's take the existing abort path to restore the old geometry.

Fixes 3ea7daa5d7fd ("md/raid10: add reshape support")
---
 drivers/md/raid10.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/raid10.c +2 -1
index 066c43154497..4ade0cf3281f 100644
@@ -4393,7 +4393,8 @@ static int raid10_start_reshape(struct mddev *mddev)
 			spin_unlock_irq(&conf->device_lock);
 			pr_warn("md/raid10:%s: array size must be reduce before number of disks\n",
 				mdname(mddev));
-			return -EINVAL;
+			ret = -EINVAL;
+			goto abort;
 		}
 		mddev->resync_max_sectors = size;
 		conf->reshape_progress = size;

base-commit: 47e1b18f38d74015cb9fd30b5ff2a1eb88e77d31

maintainer Applied
#1 lore raw
Quoted 11 lines · Chris Down

A rejected backwards RAID10 reshape can leave the array using the requested geometry because raid10_start_reshape() updates conf->geo before checking whether the new geometry can hold the current array size. If the check fails, we return -EINVAL with the new geometry still in place. Subsequent I/O then uses a layout the data hasn't been moved to, so reads can return the wrong data and writes can silently corrupt the array.

To fix this, let's take the existing abort path to restore the old geometry.

Quoted 6 lines
Fixes 3ea7daa5d7fd ("md/raid10: add reshape support")
---
  drivers/md/raid10.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

Applied

Signature · 2 lines
Thanks,
Kuai