Skip to content

Commit ce3ec15

Browse files
committed
dm-stripe: fix a possible integer overflow
JIRA: https://issues.redhat.com/browse/RHEL-119009 Upstream Status: kernel/git/torvalds/linux.git commit 1071d56 Author: Mikulas Patocka <mpatocka@redhat.com> Date: Mon Aug 11 13:17:32 2025 +0200 dm-stripe: fix a possible integer overflow 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> Reviewed-by: John Garry <john.g.garry@oracle.com> Suggested-by: Dongsheng Yang <dongsheng.yang@linux.dev> Cc: stable@vger.kernel.org Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
1 parent cf8722d commit ce3ec15

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/md/dm-stripe.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,15 @@ static void stripe_io_hints(struct dm_target *ti,
456456
struct queue_limits *limits)
457457
{
458458
struct stripe_c *sc = ti->private;
459-
unsigned int chunk_size = sc->chunk_size << SECTOR_SHIFT;
459+
unsigned int io_min, io_opt;
460460

461461
limits->chunk_sectors = sc->chunk_size;
462-
limits->io_min = chunk_size;
463-
limits->io_opt = chunk_size * sc->stripes;
462+
463+
if (!check_shl_overflow(sc->chunk_size, SECTOR_SHIFT, &io_min) &&
464+
!check_mul_overflow(io_min, sc->stripes, &io_opt)) {
465+
limits->io_min = io_min;
466+
limits->io_opt = io_opt;
467+
}
464468
}
465469

466470
static struct target_type stripe_target = {

0 commit comments

Comments
 (0)