block: Limit zone array allocation size
authorDamien Le Moal <damien.lemoal@wdc.com>
Mon, 1 Jul 2019 05:09:18 +0000 (14:09 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 28 Jul 2019 06:28:38 +0000 (08:28 +0200)
commit14700c35fb6b7ef42189f79f9b5e0613629c6deb
tree3cf602ff4a4dd4ec619f2fda43cf4ddc8e3fde05
parentfda734287b0d0cf9a303c29e85fdc7f0b044f26d
block: Limit zone array allocation size

commit 26202928fafad8bda8b478edb7e62c885be623d7 upstream.

Limit the size of the struct blk_zone array used in
blk_revalidate_disk_zones() to avoid memory allocation failures leading
to disk revalidation failure. Also further reduce the likelyhood of
such failures by using kvcalloc() (that is vmalloc()) instead of
allocating contiguous pages with alloc_pages().

Fixes: 515ce6061312 ("scsi: sd_zbc: Fix sd_zbc_report_zones() buffer allocation")
Fixes: e76239a3748c ("block: add a report_zones method")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
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>
block/blk-zoned.c
include/linux/blkdev.h