All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Li Youhong" <dayou5941@163.com>
Cc: linux-raid@vger.kernel.org, yukuai@fygo.io
Subject: Re: [PATCH v3] md: remove legacy async del_gendisk
Date: Thu, 24 Sep 2026 08:30:52 +0000	[thread overview]
Message-ID: <20260924083053.037EC1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260924081552.2564214-1-dayou5941@163.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] md: spurious -EEXIST during concurrent array allocation due to missing synchronization
--

commit 2bbedaa2916a59078e57417858612d10fe4a7cc6
Author: Li Youhong <liyouhong@kylinos.cn>
Subject: md: remove legacy async del_gendisk

This commit removes the legacy async del_gendisk mode and delayed array
deletion. It processes deletions synchronously to avoid lockdep cycles
between major_names_lock, md_misc_wq, and reconfig_mutex.

Closes: https://syzkaller.appspot.com/bug?extid=68e1f51046d68329940f

> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 680b34a63cb3d..fbe302418be97 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c

[ ... ]

> @@ -677,10 +698,15 @@ static bool mddev_put_locked(struct mddev *mddev)
>  
>  void mddev_put(struct mddev *mddev)
>  {
> +	bool complete_delete;
> +
>  	if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock))
>  		return;
>  
> -	__mddev_put(mddev);
> +	complete_delete = __mddev_put(mddev);
>  	spin_unlock(&all_mddevs_lock);
> +	if (complete_delete)
> +		mddev_complete_delete(mddev);
>  }

[Severity: Medium]
Could this create a window where a concurrent array allocation sees the
partially deleted array?

When all_mddevs_lock is dropped here, the mddev is still present in the
all_mddevs list because kobject_put has not yet run via
mddev_complete_delete.

[ ... ]

> @@ -6327,12 +6323,6 @@ struct mddev *md_alloc(dev_t dev, char *name)
>  	int unit;
>  	int error;
>  
> -	/*
> -	 * Wait for any previous instance of this device to be completely
> -	 * removed (mddev_delayed_delete).
> -	 */
> -	flush_workqueue(md_misc_wq);
> -
>  	mutex_lock(&disks_mutex);
>  	mddev = mddev_alloc(dev);
>  	if (IS_ERR(mddev)) {

[Severity: Medium]
Can this missing synchronization lead to spurious -EEXIST or -EBUSY failures
during array creation?

With flush_workqueue removed, if one thread executes mddev_put and is
preempted after dropping all_mddevs_lock but before calling
mddev_complete_delete, a concurrent md_alloc can iterate all_mddevs, find the
partially deleted array (since it does not filter out MD_DELETED devices),
and fail with -EEXIST or later during add_disk.

This might break user-space scripts that rapidly tear down and recreate
arrays, such as testing suites or mdadm.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260924081552.2564214-1-dayou5941@163.com?part=1

      reply	other threads:[~2026-09-24  8:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  8:15 [PATCH v3] md: remove legacy async del_gendisk Li Youhong
2026-09-24  8:30 ` sashiko-bot [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=20260924083053.037EC1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dayou5941@163.com \
    --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.