Linux RAID subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Masalkhi, Abd Alrhman" <abd.masalkhi@gatech.edu>
Cc: yukuai@fygo.io, linux-raid@vger.kernel.org
Subject: Re: [RFC PATCH v3 2/4] md: pass struct mdu_disk_info64 to md_add_new_disk()
Date: Wed, 07 Oct 2026 12:08:29 +0000	[thread overview]
Message-ID: <sashiko-outbox-162974@kernel.org> (raw)
In-Reply-To: <20261007115104.13884-3-abd.masalkhi@gatech.edu>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] md: uninitialized info->raid_disk evaluation outside MD_DISK_SYNC flag gate
--

commit 2e047f45700e04ece53e9f9cfd19bd6bb0bd587c
Author: Abd-Alrhman Masalkhi <abd.masalkhi@gatech.edu>

md: pass struct mdu_disk_info64 to md_add_new_disk()

The md control device passes disk information as struct mdu_disk_info64.
Make md_add_new_disk() take this structure, so that the control device
and the old ADD_NEW_DISK ioctl can share it.

> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 154ee5a65cb79..be1634ae1d09c 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -8305,6 +8305,16 @@ static bool md_ioctl_need_suspend(unsigned int cmd)
>  	}
>  }
>  
> +static void convert_to_disk_info64(struct mdu_disk_info64 *info64,
> +				   mdu_disk_info_t *info)
> +{
> +	info64->number = info->number;
> +	info64->major = info->major;
> +	info64->minor = info->minor;
> +	info64->raid_disk = info->raid_disk;

[Severity: Medium]
If the ADD_NEW_DISK ioctl is called to add a hot spare without the
MD_DISK_SYNC flag set, is it guaranteed that userspace has initialized
info->raid_disk?

Userspace is not required to initialize the raid_disk field if the
MD_DISK_SYNC flag is absent, meaning it may contain arbitrary garbage.
The convert_to_disk_info64() helper copies this unconditionally.

When md_add_new_disk() proceeds to evaluate it:

	if (info->raid_disk < mddev->raid_disks)
		rdev->raid_disk = info->raid_disk;
	else
		rdev->raid_disk = -1;

could this evaluation outside of the MD_DISK_SYNC flag gate cause array
role corruption?

If the uninitialized garbage happens to be a positive integer less than
mddev->raid_disks, rdev->raid_disk might be mistakenly assigned this
garbage value instead of the expected -1 for a spare, potentially
breaking rebuilding logic.

> +	info64->state = info->state;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261007115104.13884-1-abd.masalkhi@gatech.edu?part=2

  reply	other threads:[~2026-10-07 12:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 11:51 [RFC PATCH v3 0/4] md: add a control device for array management Masalkhi, Abd Alrhman
2026-10-07 11:51 ` [RFC PATCH v3 1/4] md: add uapi definitions for the md control device Masalkhi, Abd Alrhman
2026-10-07 11:51 ` [RFC PATCH v3 2/4] md: pass struct mdu_disk_info64 to md_add_new_disk() Masalkhi, Abd Alrhman
2026-10-07 12:08   ` sashiko-bot [this message]
2026-10-07 11:52 ` [RFC PATCH v3 3/4] md: use struct mdu_array_info64 for SET_ARRAY_INFO Masalkhi, Abd Alrhman
2026-10-07 12:01   ` sashiko-bot
2026-10-07 11:52 ` [RFC PATCH v3 4/4] md: add a control device for array management Masalkhi, Abd Alrhman
2026-10-07 12:09   ` sashiko-bot
2026-10-07 18:09     ` Masalkhi, Abd Alrhman

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=sashiko-outbox-162974@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=abd.masalkhi@gatech.edu \
    --cc=linux-raid@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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