From: Yu Kuai <yukuai1@huaweicloud.com>
To: Guillaume Morin <guillaume@morinfr.org>,
Yu Kuai <yukuai1@huaweicloud.com>
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
song@kernel.org, "yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [BUG] possible race between md_free_disk and md_notify_reboot
Date: Sat, 22 Feb 2025 09:08:10 +0800 [thread overview]
Message-ID: <fd4dc27c-501b-404d-6f96-8a4628883ccd@huaweicloud.com> (raw)
In-Reply-To: <Z7iZh56mykLW82SN@bender.morinfr.org>
Hi,
在 2025/02/21 23:19, Guillaume Morin 写道:
> 2) Instead of mddev_free() being called for mddev N+1 like in 1, I wonder
> what's preventing mddev_free() being called for mddev N (the one we're
> iterating about). Something like
>
> CPU1 CPU2
> list_for_each_entry(mddev, &all_mddevs, all_mddevs) {
> if (!mddev_get(mddev))
> continue;
> spin_unlock(&all_mddevs_lock);
> mddev_free(mddev) (same mddev as CPU1)
>
> mddev_free() does not check the active atomic, or acquire the
> reconfig_mutex/md_lock and will kfree() mddev. So the loop execution
> on CPU1 after spin_unlock() could be a UAF.
>
> So I was wondering if you could clarify what is preventing race 2?
> i.e what is preventing mddev_free(mddev) from being calling kfree(mddev)
> while the md_notify_reboot() loop is handling mddev.
I said already, please take a look how mddev_put() works, mddev_free()
can't be called untill the reference is released after mddev_get().
Thanks,
Kuai
prev parent reply other threads:[~2025-02-22 1:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-19 19:43 Guillaume Morin
2025-02-20 1:26 ` Yu Kuai
2025-02-20 3:05 ` Guillaume Morin
2025-02-20 3:19 ` Yu Kuai
2025-02-20 3:45 ` Guillaume Morin
2025-02-20 4:06 ` Yu Kuai
2025-02-20 11:55 ` Yu Kuai
2025-02-20 13:39 ` Guillaume Morin
2025-02-21 1:27 ` Yu Kuai
2025-02-21 15:19 ` Guillaume Morin
2025-02-22 1:08 ` Yu Kuai [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=fd4dc27c-501b-404d-6f96-8a4628883ccd@huaweicloud.com \
--to=yukuai1@huaweicloud.com \
--cc=guillaume@morinfr.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
--cc=yukuai3@huawei.com \
/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®