Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09c2c359 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Jens Axboe
Browse files

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: default avatarMikulas Patocka <mpatocka@redhat.com>
Fixes: 615d22a5 ("block: Fix __blkdev_issue_zeroout loop")
Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent dbec491b
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -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)
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);
}
}


/**
/**