From: Dongsheng Yang <dongsheng.yang@linux.dev>
To: Mikulas Patocka <mpatocka@redhat.com>,
Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
John Garry <john.g.garry@oracle.com>
Cc: dm-devel@lists.linux.dev
Subject: Re: [PATCH] dm-stripe: fix a possible integer overflow
Date: Mon, 7 Jul 2025 21:21:37 +0800 [thread overview]
Message-ID: <862bc5bb-13fb-41bb-85c9-84411ad9dda3@linux.dev> (raw)
In-Reply-To: <0f1d0d2d-8840-a256-d628-39e074f021c1@redhat.com>
在 7/7/2025 6:39 PM, Mikulas Patocka 写道:
> There's a possible integer overflow in stripe_io_hints if we have too
> large chunk size. Test if the overflow happened, and if it did, don't set
> limits->io_min and limits->io_opt;
>
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> Cc: stable@vger.kernel.org
>
> ---
> drivers/md/dm-stripe.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> Index: linux-2.6/drivers/md/dm-stripe.c
> ===================================================================
> --- linux-2.6.orig/drivers/md/dm-stripe.c 2025-07-06 15:02:23.000000000 +0200
> +++ linux-2.6/drivers/md/dm-stripe.c 2025-07-07 12:32:49.000000000 +0200
> @@ -456,10 +456,14 @@ static void stripe_io_hints(struct dm_ta
> struct queue_limits *limits)
> {
> struct stripe_c *sc = ti->private;
> - unsigned int chunk_size = sc->chunk_size << SECTOR_SHIFT;
> + unsigned int io_min = sc->chunk_size << SECTOR_SHIFT;
> + unsigned int io_opt = io_min * sc->stripes;
>
> - limits->io_min = chunk_size;
> - limits->io_opt = chunk_size * sc->stripes;
> + if (io_min >> SECTOR_SHIFT == sc->chunk_size &&
> + io_opt / sc->stripes == io_min) {
> + limits->io_min = io_min;
> + limits->io_opt = io_opt;
> + }
Hi Mikulas,
What about using check_xxx_overflow() ? something like:
if (check_shl_overflow(sc->chunk_size, SECTOR_SHIFT, &io_min))
return;
if (check_mul_overflow(io_min, sc->stripes, &io_opt))
return;
limits->io_min = io_min;
limits->io_opt = io_opt;
> }
>
> static struct target_type stripe_target = {
>
>
next prev parent reply other threads:[~2025-07-07 13:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-07 10:39 [PATCH] dm-stripe: fix a possible integer overflow Mikulas Patocka
2025-07-07 13:15 ` John Garry
2025-07-07 13:21 ` Dongsheng Yang [this message]
2025-07-07 13:30 ` Mikulas Patocka
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=862bc5bb-13fb-41bb-85c9-84411ad9dda3@linux.dev \
--to=dongsheng.yang@linux.dev \
--cc=agk@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=john.g.garry@oracle.com \
--cc=mpatocka@redhat.com \
--cc=snitzer@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.