summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@wdc.com>2019-07-10 13:53:10 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-07-26 09:11:04 +0200
commitb80e370c0cbd49de7b391afd51c4cc335b0aa689 (patch)
tree7b612d110da9e2eee4ca730e94d1b9e85fa8323b /block
parent72ac05ce265155709de803683f326407f4ae046b (diff)
downloadlinux-stable-b80e370c0cbd49de7b391afd51c4cc335b0aa689.tar.gz
linux-stable-b80e370c0cbd49de7b391afd51c4cc335b0aa689.tar.bz2
linux-stable-b80e370c0cbd49de7b391afd51c4cc335b0aa689.zip
block: Fix potential overflow in blk_report_zones()
commit 113ab72ed4794c193509a97d7c6d32a6886e1682 upstream. For large values of the number of zones reported and/or large zone sizes, the sector increment calculated with blk_queue_zone_sectors(q) * n in blk_report_zones() loop can overflow the unsigned int type used for the calculation as both "n" and blk_queue_zone_sectors() value are unsigned int. E.g. for a device with 256 MB zones (524288 sectors), overflow happens with 8192 or more zones reported. Changing the return type of blk_queue_zone_sectors() to sector_t, fixes this problem and avoids overflow problem for all other callers of this helper too. The same change is also applied to the bdev_zone_sectors() helper. Fixes: e76239a3748c ("block: add a report_zones method") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'block')
-rw-r--r--block/blk-zoned.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index ae7e91bd0618..3249738242b4 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -70,7 +70,7 @@ EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
static inline unsigned int __blkdev_nr_zones(struct request_queue *q,
sector_t nr_sectors)
{
- unsigned long zone_sectors = blk_queue_zone_sectors(q);
+ sector_t zone_sectors = blk_queue_zone_sectors(q);
return (nr_sectors + zone_sectors - 1) >> ilog2(zone_sectors);
}