mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] md: skip superblock validation for nonpersistent arrays
@ 2026-11-17  4:49 Zheng Shuhao
  0 siblings, 0 replies; only message in thread
From: Zheng Shuhao @ 2026-11-17  4:49 UTC (permalink / raw)
  To: linux-raid; +Cc: Song Liu, Yu Kuai, Li Nan, Xiao Ni, NeilBrown, linux-kernel

Hi,

syzbot reported a KASAN slab-out-of-bounds read in
super_90_validate() when adding a journal device to a nonpersistent
0.90-style RAID1 array.

The reproducer creates a nonpersistent RAID1 array with 35 raid slots
and then hot-adds a journal device. Nonpersistent arrays do not load an
on-disk superblock for the new device, but add_bound_rdev() still calls
validate_super() in the journal path.

For 0.90 metadata, super_90_validate() indexes sb->disks using
rdev->desc_nr. With 35 raid slots, this index can exceed the 27
descriptors available in the 0.90 superblock, resulting in an
out-of-bounds read even though there is no persistent superblock to
validate.

Skip validate_super() for nonpersistent arrays, while retaining
hot_add_disk() for both persistent and nonpersistent arrays.

Testing:

- The original syzbot C reproducer triggered KASAN in the baseline
  kernel in 4 of 5 clean runs.
- The patched kernel completed the same reproducer successfully in 3 of
  3 runs without KASAN, BUG, Oops, or kernel panic.
- Both baseline and patched kernels were built with KASAN,
  CONFIG_MD_RAID0, CONFIG_MD_RAID1, CONFIG_MD_RAID10,
  CONFIG_MD_RAID456, CONFIG_MD_LINEAR, and DEBUG_LIST enabled.
- mdadm tests 00raid1, 02r1add, 20raid5journal, and
  24raid456deadlock passed with the patched kernel.
- A baseline-versus-patched run of the remaining targeted mdadm tests
  produced identical results: 4 passed, 10 failed, and 1 skipped on
  each kernel. The common failures are in persistent 0.90 byte-order
  handling and external DDF tests; no KASAN, Oops, BUG, or panic was
  observed.
- 24raid10deadlock passed with CONFIG_FAULT_INJECTION,
  CONFIG_FAIL_MAKE_REQUEST, and CONFIG_FAULT_INJECTION_DEBUG_FS enabled.

Reported-by: syzbot+c5969d7e0a934b384fd6@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=c5969d7e0a934b384fd6
Fixes: 87d4d91616e4 ("MD: add journal with array suspended")
Signed-off-by: Zheng Shuhao <viennaoffh@gmail.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 680b34a63cb3d..308cc146b0b6c 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2992,8 +2992,9 @@ static int add_bound_rdev(struct md_rdev *rdev)
 		 * then added disks for geometry changes,
 		 * and should be added immediately.
 		 */
-		super_types[mddev->major_version].
-			validate_super(mddev, NULL/*freshest*/, rdev);
+		/* Nonpersistent arrays have no on-disk superblock to validate. */
+		if (mddev->persistent)
+			super_types[mddev->major_version].validate_super(mddev, NULL, rdev);
 		err = mddev->pers->hot_add_disk(mddev, rdev);
 		if (err) {
 			md_kick_rdev_from_array(rdev);
-- 
2.43.0

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-17  4:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17  4:49 [PATCH] md: skip superblock validation for nonpersistent arrays Zheng Shuhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®