[packages/kernel/LINUX_6_18] md: prevent adding disks with larger logical_block_size to active arrays

arekm arekm at pld-linux.org
Sun Aug 23 22:34:42 CEST 2026


commit d8564275340329e3a71dda2f9dd23e0124e26674
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sun Aug 23 22:33:53 2026 +0200

    md: prevent adding disks with larger logical_block_size to active arrays
    
    Backport 6c6b66f65e55; Patch2002 makes the pre-existing hot-add hole reachable for arrays created under >= 6.19.

 kernel-md-hotadd-lbs-guard.patch | 37 +++++++++++++++++++++++++++++++++++++
 kernel.spec                      |  2 ++
 2 files changed, 39 insertions(+)
---
diff --git a/kernel.spec b/kernel.spec
index 3a5d4a99..b3be6f3a 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -168,6 +168,7 @@ Patch500:	kernel-rt.patch
 Patch2000:	kernel-small_fixes.patch
 Patch2001:	kernel-pwc-uncompress.patch
 Patch2002:	kernel-md-lbs-forward-compat.patch
+Patch2003:	kernel-md-hotadd-lbs-guard.patch
 
 # for rescuecd
 # based on ftp://ftp.leg.uct.ac.za/pub/linux/rip/tmpfs_root-2.6.30.diff.gz
@@ -598,6 +599,7 @@ rm -f localversion-rt
 #patch -P2000 -p1
 %patch -P2001 -p1
 %patch -P2002 -p1
+%patch -P2003 -p1
 
 chmod 755 tools/objtool/sync-check.sh
 
diff --git a/kernel-md-hotadd-lbs-guard.patch b/kernel-md-hotadd-lbs-guard.patch
new file mode 100644
index 00000000..0af69f44
--- /dev/null
+++ b/kernel-md-hotadd-lbs-guard.patch
@@ -0,0 +1,37 @@
+Subject: md: prevent adding disks with larger logical_block_size to active arrays
+
+Upstream 6c6b66f65e55 ("md: prevent adding disks with larger
+logical_block_size to active arrays"), verbatim.
+
+mddev_stack_new_rdev() stacks the new member's queue limits into the
+array's, and blk_stack_limits() takes the maximum logical block size.
+Hot-adding a 4Kn disk to a 512-byte array therefore raises the logical
+block size of the live array, which makes its partition table unreadable:
+
+  mdadm -CRq /dev/md0 -l1 -n3 /dev/sd[de] missing --assume-clean
+  parted -s /dev/md0 mklabel gpt mkpart primary 1MiB 100%
+  mdadm --add -q /dev/md0 /dev/sdf	# sdf has 4096 byte LBS
+  partprobe /dev/md0			# md0p1 is gone
+
+The bug predates 2.6.12 and is reachable for every array that assembles
+here.  kernel-md-lbs-forward-compat.patch widens that set to arrays
+created under >= 6.19, so carry the upstream fix next to it.
+
+Fixed upstream in 6.19; 6.18.y has not picked it up.
+
+--- a/drivers/md/md.c
++++ b/drivers/md/md.c
+@@ -6144,6 +6144,13 @@
+ 	if (mddev_is_dm(mddev))
+ 		return 0;
+ 
++	if (queue_logical_block_size(rdev->bdev->bd_disk->queue) >
++	    queue_logical_block_size(mddev->gendisk->queue)) {
++		pr_err("%s: incompatible logical_block_size, can not add\n",
++		       mdname(mddev));
++		return -EINVAL;
++	}
++
+ 	lim = queue_limits_start_update(mddev->gendisk->queue);
+ 	queue_limits_stack_bdev(&lim, rdev->bdev, rdev->data_offset,
+ 				mddev->gendisk->disk_name);
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/kernel.git/commitdiff/d8564275340329e3a71dda2f9dd23e0124e26674



More information about the pld-cvs-commit mailing list