From: Zheng Shuhao <viennaoffh@gmail.com>
To: linux-raid@vger.kernel.org
Cc: Song Liu <song@kernel.org>, Yu Kuai <yukuai@fygo.io>,
Li Nan <magiclinan@didiglobal.com>, Xiao Ni <xiao@kernel.org>,
NeilBrown <neilb@suse.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] md: skip superblock validation for nonpersistent arrays
Date: Mon, 16 Nov 2026 20:49:05 -0800 (PST) [thread overview]
Message-ID: <6afbdcc1.e6d8240f.129280.2aea@mx.google.com> (raw)
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
reply other threads:[~2026-11-17 4:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6afbdcc1.e6d8240f.129280.2aea@mx.google.com \
--to=viennaoffh@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--cc=neilb@suse.com \
--cc=song@kernel.org \
--cc=xiao@kernel.org \
--cc=yukuai@fygo.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®