From: sashiko-bot@kernel.org
To: "Yu Kuai" <yukuai@kernel.org>
Cc: linux-raid@vger.kernel.org, yukuai@fygo.io
Subject: Re: [PATCH v4 08/25] md: add helper to split bios at reshape offset
Date: Sat, 01 Aug 2026 17:41:54 +0000 [thread overview]
Message-ID: <20260801174154.940571F00AC4@smtp.kernel.org> (raw)
In-Reply-To: <20260801172519.2982121-9-yukuai@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] READ_ONCE() on the 64-bit `mddev->reshape_position` can result in a torn read on 32-bit architectures, leading to incorrect bio splitting and silent data corruption.
--
--- Patch [8]: [PATCH v4 08/25] md: add helper to split bios at reshape offset ---
commit 71f7d05880dacfb8a18a94d6924ba3faac7d7965
Author: Yu Kuai <yukuai@fygo.io>
md: add helper to split bios at reshape offset
This commit adds mddev_bio_split_at_reshape_offset() to allow RAID
personalities to share reshape-offset bio splitting. It introduces a
lockless read of mddev->reshape_position using READ_ONCE().
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
[ ... ]
> +struct bio *mddev_bio_split_at_reshape_offset(struct mddev *mddev,
> + struct bio *bio,
> + unsigned int *max_sectors,
> + struct bio_set *bs)
> +{
> + sector_t boundary;
> + sector_t start;
> + sector_t end;
> + unsigned int split_sectors;
> +
> + split_sectors = bio_sectors(bio);
> + if (max_sectors && *max_sectors && *max_sectors < split_sectors)
> + split_sectors = *max_sectors;
> +
> + if (!test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery))
> + goto split;
> +
> + boundary = READ_ONCE(mddev->reshape_position);
> + start = bio->bi_iter.bi_sector;
> + end = bio_end_sector(bio);
> + if (start >= boundary || end <= boundary)
> + goto split;
[Severity: Critical]
Is it possible for the READ_ONCE() above to result in a torn read on 32-bit
architectures?
Since mddev->reshape_position is a sector_t (64-bit value), compiling a
READ_ONCE() on a 32-bit architecture will result in two separate 32-bit loads.
If the reshape thread concurrently updates this value without a lock, a read
could happen exactly when crossing a 32-bit boundary, producing a corrupted
boundary value.
If the torn read produces an oversized boundary value, will this bounds check
evaluate to true and incorrectly skip splitting the bio?
Passing an unsplit bio that spans both old and new geometry layouts to the
RAID personality might result in writes to incorrect disks and offsets. Before
this helper was introduced, did personalities like RAID5 use a lock (like
conf->device_lock) to prevent this 64-bit read race?
> +
> + if (boundary - start < split_sectors)
> + split_sectors = boundary - start;
> +
> +split:
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260801172519.2982121-1-yukuai@kernel.org?part=8
next prev parent reply other threads:[~2026-08-01 17:41 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-01 17:24 [PATCH v4 00/25] md: improve lockless bitmap reshape support Yu Kuai
2026-08-01 17:24 ` [PATCH v4 01/25] md/md-llbitmap: clear flush state after daemon flush Yu Kuai
2026-08-01 17:43 ` sashiko-bot
2026-08-01 17:24 ` [PATCH v4 02/25] md/md-llbitmap: use GFP_NOIO for cache allocations Yu Kuai
2026-08-01 17:41 ` sashiko-bot
2026-08-01 17:24 ` [PATCH v4 03/25] md/md-llbitmap: only end fully synced chunks Yu Kuai
2026-08-01 17:42 ` sashiko-bot
2026-08-01 17:24 ` [PATCH v4 04/25] md/raid5: reject zero-sector reshape chunks Yu Kuai
2026-08-01 17:45 ` sashiko-bot
2026-08-01 17:24 ` [PATCH v4 05/25] md/raid5: round bitmap stripes with sector division Yu Kuai
2026-08-01 17:39 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 06/25] md: add exact bitmap mapping and reshape hooks Yu Kuai
2026-08-01 17:25 ` [PATCH v4 07/25] md: skip bitmap accounting for empty write ranges Yu Kuai
2026-08-01 18:05 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 08/25] md: add helper to split bios at reshape offset Yu Kuai
2026-08-01 17:41 ` sashiko-bot [this message]
2026-08-01 17:25 ` [PATCH v4 09/25] md/md-llbitmap: track bitmap sync_size explicitly Yu Kuai
2026-08-01 17:44 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 10/25] md/md-llbitmap: allocate page controls independently Yu Kuai
2026-08-01 17:47 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 11/25] md/md-llbitmap: grow the page cache in place for reshape Yu Kuai
2026-08-01 18:03 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 12/25] md/md-llbitmap: track target reshape geometry fields Yu Kuai
2026-08-01 17:51 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 13/25] md/md-llbitmap: finish reshape geometry Yu Kuai
2026-08-01 17:59 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 14/25] md/md-llbitmap: refuse reshape while llbitmap still needs sync Yu Kuai
2026-08-01 17:50 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 15/25] md/md-llbitmap: add reshape range mapping helpers Yu Kuai
2026-08-01 17:47 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 16/25] md/md-llbitmap: don't skip reshape ranges from bitmap state Yu Kuai
2026-08-01 17:41 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 17/25] md/md-llbitmap: remap checkpointed bits as reshape progresses Yu Kuai
2026-08-01 18:12 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 18/25] md/md-llbitmap: clamp state-machine walks to tracked bits Yu Kuai
2026-08-01 17:55 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 19/25] md/raid10: reject llbitmap reshape when md chunk shrinks Yu Kuai
2026-08-01 17:25 ` [PATCH v4 20/25] md/raid10: wire llbitmap reshape lifecycle Yu Kuai
2026-08-01 18:28 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 21/25] md/raid10: split reshape bios before bitmap accounting Yu Kuai
2026-08-01 17:59 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 22/25] md/raid5: add exact old and new llbitmap mapping helpers Yu Kuai
2026-08-01 18:05 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 23/25] md/raid5: reject llbitmap reshape when md chunk shrinks Yu Kuai
2026-08-01 17:25 ` [PATCH v4 24/25] md/raid5: wire llbitmap reshape lifecycle Yu Kuai
2026-08-01 18:12 ` sashiko-bot
2026-08-01 17:25 ` [PATCH v4 25/25] md/raid5: split reshape bios before bitmap accounting Yu Kuai
2026-08-01 18:43 ` sashiko-bot
2026-08-02 16:13 ` [PATCH v4 00/25] md: improve lockless bitmap reshape support Mykola Marzhan
2026-08-02 19:13 ` yu kuai
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=20260801174154.940571F00AC4@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yukuai@fygo.io \
--cc=yukuai@kernel.org \
/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