From: "Coly Li" <colyli@fnnas.com>
To: <mingzhe.zou@easystack.cn>
Cc: <colyli@kernel.org>, <linux-bcache@vger.kernel.org>,
<zoumingzhe@qq.com>, <zoumingzhe@outlook.com>
Subject: Re: [PATCH] bcache: fix uninitialized closure object
Date: Fri, 3 Apr 2026 12:04:04 +0800 [thread overview]
Message-ID: <ac87Xq4zNhOJ64Cx@loaclhost> (raw)
In-Reply-To: <20260402130353.1099802-1-mingzhe.zou@easystack.cn>
On Thu, Apr 02, 2026 at 09:03:53PM +0800, mingzhe.zou@easystack.cn wrote:
> From: Mingzhe Zou <zoumingzhe@qq.com>
>
> In the previous patch(bcache: fix cached_dev.sb_bio use-after-free and crash),
> we adopted a simple modification suggestion from AI to fix the use-after-free.
>
> But in actual testing, we found an extreme case where the device is stopped
> before calling bch_write_bdev_super().
>
> At this point, struct closure sb_write has not been initialized yet.
>
> For this patch, we ensure that sb_bio has been completed via sb_write_mutex.
>
> Signed-off-by: Mingzhe Zou <mingzhe.zou@easystack.cn>
It looks good to me. I will refine the commit log and submit.
Thanks.
Coly Li
> ---
> drivers/md/bcache/super.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index 6627a381f65a..97d9adb0bf96 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -1378,7 +1378,8 @@ static CLOSURE_CALLBACK(cached_dev_free)
> * The sb_bio is embedded in struct cached_dev, so we must
> * ensure no I/O is in progress.
> */
> - closure_sync(&dc->sb_write);
> + down(&dc->sb_write_mutex);
> + up(&dc->sb_write_mutex);
>
> if (dc->sb_disk)
> folio_put(virt_to_folio(dc->sb_disk));
> --
> 2.34.1
next prev parent reply other threads:[~2026-04-03 4:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 13:03 [PATCH] bcache: fix uninitialized closure object mingzhe.zou
2026-04-03 4:04 ` Coly Li [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-04-03 4:21 colyli
2026-04-03 11:11 ` Jens Axboe
2026-04-07 9:28 ` Coly Li
2026-04-07 12:44 ` Jens Axboe
2026-04-07 13:19 ` Coly Li
2026-04-07 13:24 ` Jens Axboe
2026-04-07 14:09 ` Coly Li
2026-04-03 11:11 ` Jens Axboe
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=ac87Xq4zNhOJ64Cx@loaclhost \
--to=colyli@fnnas.com \
--cc=colyli@kernel.org \
--cc=linux-bcache@vger.kernel.org \
--cc=mingzhe.zou@easystack.cn \
--cc=zoumingzhe@outlook.com \
--cc=zoumingzhe@qq.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