[PATCH] block: Fix potential overflow in blk_report_zones()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For large values of the number of zones reported, the sector increment
calculated with "blk_queue_zone_sectors(q) * n" can overflow the
unsigned int type used. Fix this with a cast to sector_t type.

Fixes: e76239a3748c ("block: add a report_zones method")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Damien Le Moal <damien.lemoal@xxxxxxx>
---
 block/blk-zoned.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 79ad269b545d..231b7e1b6d22 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -134,7 +134,7 @@ static int blk_report_zones(struct gendisk *disk, sector_t sector,
 			return ret;
 		if (!n)
 			break;
-		sector += blk_queue_zone_sectors(q) * n;
+		sector += (sector_t)blk_queue_zone_sectors(q) * n;
 		z += n;
 	}
 
-- 
2.21.0




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux