Skip to content

Commit

Permalink
block: Limit allocation of zone descriptors for report zones
Browse files Browse the repository at this point in the history
There is no point in allocating more zone descriptors than the number of
zones a block device has for doing a zone report. Avoid doing that in
blkdev_report_zones_ioctl() by limiting the number of zone decriptors
allocated internally to process the user request.

Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Signed-off-by: Damien Le Moal <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
damien-lemoal authored and axboe committed Oct 25, 2018
1 parent a91e138 commit 2e85fba
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions block/blk-zoned.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
if (!rep.nr_zones)
return -EINVAL;

if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone))
return -ERANGE;
rep.nr_zones = min(blkdev_nr_zones(bdev), rep.nr_zones);

zones = kvmalloc_array(rep.nr_zones, sizeof(struct blk_zone),
GFP_KERNEL | __GFP_ZERO);
Expand Down

0 comments on commit 2e85fba

Please sign in to comment.