mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: syzbot <syzbot+9e3014263a35700ab49b@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org
Subject: Forwarded: [PATCH] configfs: unhash dentry before dropping the item
Date: Mon, 14 Sep 2026 00:44:25 -0700	[thread overview]
Message-ID: <6aa7a5d9.f81106d8.2ab401.0047.GAE@google.com> (raw)
In-Reply-To: <6aa6a091.f670cee1.72fc4.0012.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.

***

Subject: [PATCH] configfs: unhash dentry before dropping the item
Author: jchuang26@m.fudan.edu.cn

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

Reported-by: syzbot+9e3014263a35700ab49b@syzkaller.appspotmail.com

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 680b34a63..bcc32b83c 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1393,7 +1393,11 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
 		goto abort;
 	}
 
-	if (sb->raid_disks <= 0)
+	/*
+	 * sb->disks[] has only MD_SB_DISKS entries.  A larger raid_disks
+	 * count would later make super_90_sync() index past that array.
+	 */
+	if (sb->raid_disks <= 0 || sb->raid_disks > MD_SB_DISKS)
 		goto abort;
 
 	if (md_csum_fold(calc_sb_csum(sb)) != md_csum_fold(sb->sb_csum)) {
@@ -1607,6 +1611,18 @@ static void super_90_sync(struct mddev *mddev, struct md_rdev *rdev)
 	struct md_rdev *rdev2;
 	int next_spare = mddev->raid_disks;
 
+	/*
+	 * A 0.90 superblock has a fixed-size mdp_disk_t array and uses
+	 * raid_disks as both a loop bound and the first spare disk slot.
+	 * Never index sb->disks[] if an invalid raid_disks value reached
+	 * us through any configuration path.
+	 */
+	if (mddev->raid_disks < 0 || mddev->raid_disks > MD_SB_DISKS) {
+		pr_warn("md: %s: invalid raid_disks %d for 0.90 metadata\n",
+			mdname(mddev), mddev->raid_disks);
+		return;
+	}
+
 	/* make rdev->sb match mddev data..
 	 *
 	 * 1/ zero out disks
@@ -4448,8 +4464,19 @@ raid_disks_store(struct mddev *mddev, const char *buf, size_t len)
 		mddev->delta_disks = n - olddisks;
 		mddev->raid_disks = n;
 		mddev->reshape_backwards = (mddev->delta_disks < 0);
-	} else
-		mddev->raid_disks = n;
+	} else {
+		/*
+		 * 0.90 metadata only has room for MD_SB_DISKS descriptors.
+		 * Larger values would make super_90_sync() index beyond
+		 * sb->disks[].
+		 */
+		if ((mddev->persistent && mddev->major_version == 0 &&
+		     n > MD_SB_DISKS) ||
+		    (mddev->max_disks && n > mddev->max_disks))
+			err = -EINVAL;
+		else
+			mddev->raid_disks = n;
+	}
 out_unlock:
 	memalloc_noio_restore(noio_flags);
 	mddev_unlock_and_resume(mddev);
@@ -7926,6 +7953,18 @@ int md_set_array_info(struct mddev *mddev, struct mdu_array_info_s *info)
 		mddev->ctime         = ktime_get_real_seconds();
 		return 0;
 	}
+
+	/*
+	 * Persistent 0.90 metadata stores disks in sb->disks[MD_SB_DISKS].
+	 * A larger raid_disks count would make super_90_sync() index past
+	 * that array; non-persistent arrays have no such on-disk limit.
+	 */
+	if (info->raid_disks < 0 ||
+	    (!info->not_persistent && info->raid_disks > MD_SB_DISKS)) {
+		pr_warn("md: invalid raid_disks %d\n", info->raid_disks);
+		return -EINVAL;
+	}
+
 	mddev->major_version = MD_MAJOR_VERSION;
 	mddev->minor_version = MD_MINOR_VERSION;
 	mddev->patch_version = MD_PATCHLEVEL_VERSION;

  parent reply	other threads:[~2026-09-14  7:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-13 13:09 [syzbot] [raid?] UBSAN: array-index-out-of-bounds in super_90_sync syzbot
2026-09-13 17:34 ` syzbot
2026-09-14  3:52 ` Forwarded: [PATCH] md: validate raid_disks against MD_SB_DISKS in super_90_load syzbot
2026-09-14  4:22 ` Forwarded: [PATCH] md: fix out-of-bounds access to superblock disk array syzbot
2026-09-14  7:44 ` syzbot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-09-13  2:47 [syzbot] [batman?] WARNING in batadv_iv_ogm_process_per_outif syzbot
2026-09-14  6:56 ` Forwarded: [PATCH] configfs: unhash dentry before dropping the item syzbot
2026-09-14  7:10 ` syzbot
2026-08-16 15:10 [syzbot] [kernel?] BUG: unable to handle kernel paging request in cirrus_primary_plane_helper_atomic_update syzbot
2026-09-13  9:04 ` Forwarded: [PATCH] configfs: unhash dentry before dropping the item syzbot
2026-09-14  1:12 ` syzbot
2026-08-06 15:37 [syzbot] [block?] UBSAN: shift-out-of-bounds in null_process_zoned_cmd syzbot
2026-09-14  4:19 ` Forwarded: [PATCH] configfs: unhash dentry before dropping the item syzbot
2026-09-14  4:21 ` syzbot
2026-09-14  5:06 ` syzbot
2026-08-01  0:44 [syzbot] [usb?] UBSAN: array-index-out-of-bounds in uea_bind syzbot
2026-09-14  5:48 ` Forwarded: [PATCH] configfs: unhash dentry before dropping the item syzbot
2026-09-14  5:49 ` syzbot
2026-07-30  0:19 [syzbot] [fs?] KASAN: slab-use-after-free Write in config_item_get syzbot
2026-09-10 12:24 ` Forwarded: [PATCH] configfs: unhash dentry before dropping the item syzbot
2026-09-11  8:15 ` syzbot
2026-09-11 11:55 ` syzbot
2026-09-14  1:38 ` syzbot

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=6aa7a5d9.f81106d8.2ab401.0047.GAE@google.com \
    --to=syzbot+9e3014263a35700ab49b@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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®