From: "Masalkhi, Abd Alrhman" <abd.masalkhi@gatech.edu>
To: "sashiko-reviews@lists.linux.dev" <sashiko-reviews@lists.linux.dev>
Cc: "yukuai@fygo.io" <yukuai@fygo.io>,
"linux-raid@vger.kernel.org" <linux-raid@vger.kernel.org>
Subject: Re: [RFC PATCH v3 4/4] md: add a control device for array management
Date: Wed, 7 Oct 2026 18:09:22 +0000 [thread overview]
Message-ID: <m2h5ixbcxa.fsf@gmail.com> (raw)
In-Reply-To: <sashiko-outbox-162977@kernel.org>
Hi Kuai,
On Wed, Oct 07, 2026 at 12:09 +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issu=(s) to consider:
> - [High] md: MD_CLOSING mutual exclusion broken in mdctl_ioctl
> --
>
> commit fe7502eb38662870e8ecf28880f3055a33951d2a
> Author: Abd-Alrhman Masalkhi <abd.masalkhi@gatech.edu>
>
> md: add a control device for array management
>
> This commit adds a misc character device, /dev/md-control, to handle md
> management ioctls without opening the md block device. This aims to resol=e
> an issue where STOP_ARRAY races with concurrent writes from tasks sharing
> the same file descriptor table.
>
>> diff --git a/drivers/md/md.c b/drivers/md/md.c
>> --- a/drivers/md/md.c
>> +++ b/drivers/md/md.c
> [ ... ]
>> +static long mdctl_ioctl(struct file *filp, uint cmd, ulong u)
>> +{
> [ ... ]
>> + if (cmd == MD_STOP_ARRAY) {
>> + /* Need to flush page cache, and ensure no openers */
>> + err = mddev_set_closing_and_sync_blockdev(mddev, 0);
>> + if (err)
>> + goto out;
>> + }
> [ ... ]
>> +out:
>> + if (cmd == MD_STOP_ARRAY)
Sorry I do not fix it correctly. I'll fix it in the next version.
>> + clear_bit(MD_CLOSING, &mddev->flags);
>> +
>> + mddev_put(mddev);
>> + return err;
>> +}
>
> [Severity: High]
> Does this unconditional clearance of MD_CLOSING destroy mutual exclusion =or
> concurrent stop attempts?
>
> If two tasks call mdctl_ioctl() with MD_STOP_ARRAY concurrently:
>
> Task A succeeds in mddev_set_closing_and_sync_blockdev(), which sets
> MD_CLOSING.
>
> Task B fails in mddev_set_closing_and_sync_blockdev() because MD_CLOSING =s
> already set, returning -EBUSY and jumping to out.
>
> Task B then unconditionally clears MD_CLOSING at the out label.
>
> This clears the flag while Task A is still relying on it to prevent
> concurrent openers or operations, potentially circumventing the protectio=s
> this patch aims to provide. Should this bit only be cleared if the task
> actually set it, or removed entirely if the old md_ioctl() didn't need to
> clear it here?
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261007115104.13=84-1-abd.masalkhi@gatech.edu?part=4
>
--
Best Regards,
Abd-Alrhman
prev parent reply other threads:[~2026-10-07 18:09 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
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 [this message]
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=m2h5ixbcxa.fsf@gmail.com \
--to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.