Message ID | 021c1029a42253c749a182a38d9709c2cd8db0df.camel@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Jun 13, 2018 at 03:36:42PM +0000, Bart Van Assche wrote: > Hello stable kernel maintainers, > > Please backport patch 327ea4adcfa3 ("blkdev_report_zones_ioctl(): > Use vmalloc() to allocate large buffers") to at least the v4.17.x and > v4.14.y stable kernel series. That patch fixes a bug introduced in > kernel v4.10. The entire patch is shown below. It's already in my queue to apply, and I normally wait until after it shows up in a -rc release before queueing it up. But I'll go do so now, thanks. greg k-h
diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 08e84ef2bc05..3d08dc84db16 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -328,7 +328,11 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, if (!rep.nr_zones) return -EINVAL; - zones = kcalloc(rep.nr_zones, sizeof(struct blk_zone), GFP_KERNEL); + if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone)) + return -ERANGE; + + zones = kvmalloc(rep.nr_zones * sizeof(struct blk_zone), + GFP_KERNEL | __GFP_ZERO); if (!zones) return -ENOMEM; @@ -350,7 +354,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, } out: - kfree(zones); + kvfree(zones); return ret; }