]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dm-stripe: fix a possible integer overflow
authorMikulas Patocka <mpatocka@redhat.com>
Mon, 11 Aug 2025 11:17:32 +0000 (13:17 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Sep 2025 09:13:45 +0000 (11:13 +0200)
commit 1071d560afb4c245c2076494226df47db5a35708 upstream.

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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-stripe.c

index c68dc1653cfd1b27b2a3afe731d062298e7ef3e6..cbf4c102c4d0c0ba006754f22c61e689c923a35c 100644 (file)
@@ -457,11 +457,15 @@ static void stripe_io_hints(struct dm_target *ti,
                            struct queue_limits *limits)
 {
        struct stripe_c *sc = ti->private;
-       unsigned int chunk_size = sc->chunk_size << SECTOR_SHIFT;
+       unsigned int io_min, io_opt;
 
        limits->chunk_sectors = sc->chunk_size;
-       limits->io_min = chunk_size;
-       limits->io_opt = chunk_size * sc->stripes;
+
+       if (!check_shl_overflow(sc->chunk_size, SECTOR_SHIFT, &io_min) &&
+           !check_mul_overflow(io_min, sc->stripes, &io_opt)) {
+               limits->io_min = io_min;
+               limits->io_opt = io_opt;
+       }
 }
 
 static struct target_type stripe_target = {