diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2017-09-11 09:46:49 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2017-09-11 09:46:49 -0600 |
commit | 09c2c359be546df45be0b158ea1d3cc8ea83c876 (patch) | |
tree | cd686e4707bc782debea2ad4ba6dbf8cad5b3048 /block | |
parent | dbec491b12b52888d120e5be8f15886b3216eb19 (diff) | |
download | linux-stable-09c2c359be546df45be0b158ea1d3cc8ea83c876.tar.gz linux-stable-09c2c359be546df45be0b158ea1d3cc8ea83c876.tar.bz2 linux-stable-09c2c359be546df45be0b158ea1d3cc8ea83c876.zip |
block: fix integer overflow in __blkdev_sectors_to_bio_pages()
Fix possible integer overflow in __blkdev_sectors_to_bio_pages if
sector_t is 32-bit.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: 615d22a51c04 ("block: Fix __blkdev_issue_zeroout loop")
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-lib.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/block/blk-lib.c b/block/blk-lib.c index e01adb5145b3..62240f8832ca 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -269,9 +269,9 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev, */ static unsigned int __blkdev_sectors_to_bio_pages(sector_t nr_sects) { - sector_t bytes = (nr_sects << 9) + PAGE_SIZE - 1; + sector_t pages = DIV_ROUND_UP_SECTOR_T(nr_sects, PAGE_SIZE / 512); - return min(bytes >> PAGE_SHIFT, (sector_t)BIO_MAX_PAGES); + return min(pages, (sector_t)BIO_MAX_PAGES); } /** |