From: Paul Menzel <pmenzel@molgen.mpg.de>
To: Junrui Luo <moonafterrain@outlook.com>
Cc: Song Liu <song@kernel.org>, Yu Kuai <yukuai@fnnas.com>,
Li Nan <linan122@huawei.com>, NeilBrown <neil@brown.name>,
Jonathan Brassow <jbrassow@redhat.com>,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
Yuhao Jiang <danisjiang@gmail.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] md/raid10: fix divide-by-zero in setup_geo() with zero far_copies
Date: Thu, 16 Apr 2026 08:17:26 +0200 [thread overview]
Message-ID: <803b6b1c-6aef-43e0-89e2-3d0f1308e892@molgen.mpg.de> (raw)
In-Reply-To: <SYBPR01MB7881A5E2556806CC1D318582AF232@SYBPR01MB7881.ausprd01.prod.outlook.com>
Dear Junrui,
Thank you for the patch.
Am 16.04.26 um 05:39 schrieb Junrui Luo:
> setup_geo() extracts near_copies (nc) and far_copies (fc) from the
> user-provided layout parameter without checking for zero. When fc=0
> with the "improved" far set layout selected, 'geo->far_set_size =
> disks / fc' triggers a divide-by-zero.
>
> Validate nc and fc immediately after extraction, returning -1 if
> either is zero.
Why also `nc` and not just `fc`?
It’d be great, if you documented the command how to create such a layout.
> Fixes: 475901aff158 ("MD RAID10: Improve redundancy for 'far' and 'offset' algorithms (part 1)")
> Reported-by: Yuhao Jiang <danisjiang@gmail.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
> ---
> drivers/md/raid10.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 0653b5d8545a..811ea3d23b80 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -3791,6 +3791,8 @@ static int setup_geo(struct geom *geo, struct mddev *mddev, enum geo_type new)
> nc = layout & 255;
> fc = (layout >> 8) & 255;
> fo = layout & (1<<16);
> + if (!nc || !fc)
> + return -1;
I’d also print a warning, so the user knows, what was wrong:
pr_warn(md/raid10:%s: near and far copies need to be greater than
0, mdname(mddev));
> geo->raid_disks = disks;
> geo->near_copies = nc;
> geo->far_copies = fc;
Kind regards,
Paul
next prev parent reply other threads:[~2026-04-16 6:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 3:39 Junrui Luo
2026-04-16 6:17 ` Paul Menzel [this message]
2026-04-16 10:08 ` Junrui Luo
2026-04-19 5:43 ` Yu Kuai
2026-04-19 6:01 ` Yuhao Jiang
[not found] ` <CAHYQsXRN6uof4yyDR6qGteQ=wZTt86VUx7km6k=LbNAQ3wxGiQ@mail.gmail.com>
2026-04-28 8:32 ` Yu Kuai
2026-04-28 8:37 ` Yuhao Jiang
2026-05-20 11:52 ` Yu Kuai
2026-05-20 16:43 ` Yuhao Jiang
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=803b6b1c-6aef-43e0-89e2-3d0f1308e892@molgen.mpg.de \
--to=pmenzel@molgen.mpg.de \
--cc=danisjiang@gmail.com \
--cc=jbrassow@redhat.com \
--cc=linan122@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=moonafterrain@outlook.com \
--cc=neil@brown.name \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
--cc=yukuai@fnnas.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®