From: "Yu Kuai" <yukuai@fnnas.com>
To: "Benjamin Marzinski" <bmarzins@redhat.com>,
"Song Liu" <song@kernel.org>, "Li Nan" <linan122@huawei.com>,
"Xiao Ni" <xni@redhat.com>, <yukuai@fnnas.com>
Cc: <linux-raid@vger.kernel.org>, <dm-devel@lists.linux.dev>,
"Nigel Croxon" <ncroxon@redhat.com>
Subject: Re: [PATCH v2] md/raid5: Fix UAF on IO across the reshape position
Date: Sun, 19 Apr 2026 11:51:10 +0800 [thread overview]
Message-ID: <8764280f-f478-44b5-8bb7-013b9d8e0aaa@fnnas.com> (raw)
In-Reply-To: <20260408043548.1695157-1-bmarzins@redhat.com>
在 2026/4/8 12:35, Benjamin Marzinski 写道:
> If make_stripe_request() returns STRIPE_WAIT_RESHAPE,
> raid5_make_request() will free the cloned bio. But raid5_make_request()
> can call make_stripe_request() multiple times, writing to the various
> stripes. If that bio got added to the toread or towrite lists of a
> stripe disk in an earlier call to make_stripe_request(), then it's not
> safe to just free the bio if a later part of it is found to cross the
> reshape position. Doing so can lead to a UAF error, when bio_endio()
> is called on the bio for the earlier stripes.
>
> Instead, raid5_make_request() needs to wait until all parts of the bio
> have called bio_endio(). To do this, bios that cross the reshape
> position while the reshape can't make progress are flagged as needing to
> wait for all parts to complete. When raid5_make_request() has a bio that
> failed make_stripe_request() with STRIPE_WAIT_RESHAPE, it sets
> bi->bi_private to a completion struct and waits for completion after
> ending the bio. When the bio_endio() is called for the last time on a
> clone bio with bi->bi_private set, it wakes up the waiter. This
> guarantees that raid5_make_request() doesn't return until the cloned bio
> needing a retry for io across the reshape boundary is safely cleaned up.
>
> There is a simple reproducer available at [1]. Compile the kernel with
> KASAN for more useful reporting when the error is triggered (this is not
> necessary to see the bug).
>
> [1]https://gist.github.com/bmarzins/e48598824305cf2171289e47d7241fa5
>
> Signed-off-by: Benjamin Marzinski<bmarzins@redhat.com>
> ---
>
> Changes from v1:
> - Removed mddev->pending_retry_bios, mddev->retry_bios_wait, and
> md_io_clone->must_retry. Instead, use a completion struct
> pointed to by bi->bi_private, as suggested by Xiao Ni and Yu Kuai.
>
> drivers/md/md.c | 31 ++++++++-----------------------
> drivers/md/md.h | 1 -
> drivers/md/raid5.c | 7 ++++++-
> 3 files changed, 14 insertions(+), 25 deletions(-)
Applied
--
Thansk,
Kuai
prev parent reply other threads:[~2026-04-19 3:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 4:35 [PATCH v2] md/raid5: Fix UAF on IO across the reshape position Benjamin Marzinski
2026-04-08 11:22 ` Xiao Ni
2026-04-08 19:57 ` Benjamin Marzinski
2026-04-09 2:31 ` Xiao Ni
2026-04-13 2:08 ` Xiao Ni
2026-04-13 2:07 ` Xiao Ni
2026-04-19 3:51 ` 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=8764280f-f478-44b5-8bb7-013b9d8e0aaa@fnnas.com \
--to=yukuai@fnnas.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=linan122@huawei.com \
--cc=linux-raid@vger.kernel.org \
--cc=ncroxon@redhat.com \
--cc=song@kernel.org \
--cc=xni@redhat.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