From: "yu kuai" <yukuai@fygo.io>
To: "Chen Cheng" <chencheng@fnnas.com>, <linux-raid@vger.kernel.org>,
"yu kuai" <yukuai@fygo.io>
Cc: <linux-kernel@vger.kernel.org>, "Mykola Marzhan" <mykola@meshstor.io>
Subject: Re: [PATCH v6 0/3] md/raid10: fix r10bio width mismatches across reshape
Date: Fri, 31 Jul 2026 08:40:46 +0800 [thread overview]
Message-ID: <9199e9d4-4023-46dc-8eda-431ce3307c88@fygo.io> (raw)
In-Reply-To: <20260711100352.425177-1-chencheng@fnnas.com>
Hi,
在 2026/7/11 18:03, Chen Cheng 写道:
> From: Chen Cheng <chencheng@fnnas.com>
>
> Hi,
>
> This series fixes slab out-of-bounds accesses in raid10 when reshape changes
> the number of raid disks while regular I/O is still reusing r10bio objects
> allocated under the previous geometry.
>
> The bug is reproducible with a simple 4-disk to 5-disk reshape under write
> load, for example:
>
> mdadm -C /dev/md777 -l10 -n4 /dev/sda /dev/sdb /dev/sdc /dev/sdd
> mkfs.ext4 /dev/md777
> mount /dev/md777 /mnt/test
> fsstress -d /mnt/test -n 24000 -p 8 -l 24 &
> mdadm /dev/md777 --add /dev/sde
> mdadm --grow /dev/md777 --raid-devices=5 \
> --backup-file=/tmp/md-reshape-backup
>
>
> KASAN report:
>
> BUG: KASAN: slab-out-of-bounds in free_r10bio+0x1c4/0x260 [raid10]
> Read of size 8 at addr ffff00008c2dfac8 by task ksoftirqd/0/15
> free_r10bio
> raid_end_bio_io
> one_write_done
> raid10_end_write_request
>
>
> This series addresses the problem in three steps:
>
> 1. ensure the sync_action=reshape caller suspends and locks before start_reshape
>
> 2. resize r10bio_pool when reshape grows raid_disks
>
> 3. reorder the r10bio free flow before bio_endio in the regular and discard
> completion paths
>
> Changes in v7:
> - patch #1, refactor out suspend from retry block
> - patch #3, raid_end_bio_io() refactor to:
> free(r10_bio) -> free(master_bio) -> allow_barrier
>
> Changes in v6:
> - suspend the array in action_store() after flush_work()
> - free r10bio before ending the discard master bio
>
> Changes in v5 (suggested by Yu Kuai):
> - simplify patch 2
> - switch patch 3 from bounding reused r10bio devs[] walks by used_nr_devs
> to reordering the free/endio flow
>
> Changes in v4:
> - make the sync_action=reshape path invoke mddev_suspend_and_lock() before
> calling start_reshape()
> - leave the md-cluster and dm-raid paths unchanged; they still reach
> start_reshape() with the mddev locked but without suspend
>
> Changes in v3:
> - replace freeze_array()/unfreeze_array() in raid10_start_reshape() with
> mddev_suspend_and_lock_nointr()/mddev_unlock_and_resume(); freeze_array()
> can return while retry-list items still hold pool objects, while
> mddev_suspend() provides the correct upper-layer quiesce interface
>
> Changes in v2:
> - add this cover letter
> - convert r10bio_pool to a fixed-size kmalloc mempool
> - rebuild r10bio_pool inside the freeze window before switching live reshape
> geometry
> - switch raid10_quiesce() to freeze_array()/unfreeze_array()
>
>
> Testing:
> - reproduced the original KASAN slab-out-of-bounds on 4-disk -> 5-disk
> raid10 reshape with fsstress
> - verified that this series fixes that reproducer
> - exercised the 5-disk -> 4-disk reshape direction as well
>
> Thanks,
> Chen Cheng
>
>
>
> Chen Cheng (3):
> md: suspend array when sync_action=reshape
> md/raid10: resize r10bio_pool for reshape
> md/raid10: free r10bio before ending master_bio in raid_end_bio_io()
> and raid_end_discard_bio()
>
> drivers/md/md.c | 17 +++++++++----
> drivers/md/raid10.c | 61 ++++++++++++++++++++++++++++++++-------------
> drivers/md/raid10.h | 2 +-
> 3 files changed, 56 insertions(+), 24 deletions(-)
Applied to md-7.3 with a few changes, please check the latest md-7.3 branch:
- Patch 2: removed the redundant if (new_pool) before mempool_destroy(new_pool) to fix the
strict checkpatch warning.
- Patch 3: rewrote raid_end_bio_io() minimally so the existing R10BIO_* bit-test lines stay in
place and checkpatch no longer flags CamelCase additions. This also preserves setting
R10BIO_Returned in r10_bio->state before freeing.
- Patch 3 commit message: corrected the listed final order to free_r10bio() -> bio_endio() ->
allow_barrier().
>
--
Thanks,
Kuai
next prev parent reply other threads:[~2026-07-31 0:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 10:03 Chen Cheng
2026-07-11 10:03 ` [PATCH v7 1/3] md: suspend array when sync_action=reshape Chen Cheng
2026-07-11 10:03 ` [PATCH v7 2/3] md/raid10: resize r10bio_pool for reshape Chen Cheng
2026-07-11 10:03 ` [PATCH v7 3/3] md/raid10: free r10bio before ending master_bio in raid_end_bio_io() and raid_end_discard_bio() Chen Cheng
2026-07-11 17:43 ` yu kuai
2026-07-18 12:30 ` Chen Cheng
2026-07-26 18:56 ` [PATCH v7 0/3] md/raid10: fix r10bio width mismatches across reshape Mykola Marzhan
2026-07-27 3:07 ` Chen Cheng
2026-07-27 10:54 ` Mykola Marzhan
2026-07-27 11:17 ` Chen Cheng
2026-07-31 0:40 ` yu kuai [this message]
2026-07-31 10:13 ` [PATCH v6 " Mykola Marzhan
-- strict thread matches above, loose matches on Subject: below --
2026-06-23 12:38 Chen Cheng
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=9199e9d4-4023-46dc-8eda-431ce3307c88@fygo.io \
--to=yukuai@fygo.io \
--cc=chencheng@fnnas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=mykola@meshstor.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 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®