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 4/4] md: add a control device for array management
Date: Wed, 07 Oct 2026 12:09:41 +0000 [thread overview]
Message-ID: <sashiko-outbox-162977@kernel.org> (raw)
In-Reply-To: <20261007115104.13884-5-abd.masalkhi@gatech.edu>
Thank you for your contribution! Sashiko AI review found 1 potential issue(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 resolve
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)
> + clear_bit(MD_CLOSING, &mddev->flags);
> +
> + mddev_put(mddev);
> + return err;
> +}
[Severity: High]
Does this unconditional clearance of MD_CLOSING destroy mutual exclusion for
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 is
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 protections
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.13884-1-abd.masalkhi@gatech.edu?part=4
next prev parent reply other threads:[~2026-10-07 12: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 [this message]
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-162977@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 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.