linux/drivers/block
Damien Le Moal 0ebcdd702f null_blk: Fix zone size initialization
For a null_blk device with zoned mode enabled is currently initialized
with a number of zones equal to the device capacity divided by the zone
size, without considering if the device capacity is a multiple of the
zone size. If the zone size is not a divisor of the capacity, the zones
end up not covering the entire capacity, potentially resulting is out
of bounds accesses to the zone array.

Fix this by adding one last smaller zone with a size equal to the
remainder of the disk capacity divided by the zone size if the capacity
is not a multiple of the zone size. For such smaller last zone, the zone
capacity is also checked so that it does not exceed the smaller zone
size.

Reported-by: Naohiro Aota <naohiro.aota@wdc.com>
Fixes: ca4b2a0119 ("null_blk: add zone support")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-12-07 17:36:03 -07:00
..
aoe block: lift setting the readahead size into the block layer 2020-09-24 13:43:39 -06:00
drbd block-5.10-2020-10-12 2020-10-13 12:12:44 -07:00
mtip32xx blk-mq: move failure injection out of blk_mq_complete_request 2020-06-24 09:15:57 -06:00
paride paride/pcd: use bdev_check_media_change 2020-09-10 09:32:31 -06:00
rnbd block/rnbd: fix a null pointer dereference on dev->blk_symlink_name 2020-12-07 08:00:32 -07:00
rsxx rsxx: Use fallthrough pseudo-keyword 2020-10-02 17:54:45 -06:00
xen-blkback xen-blkback: add a parameter for disabling of persistent grants 2020-10-21 07:15:13 -05:00
zram block-5.10-2020-10-24 2020-10-24 12:46:42 -07:00
amiflop.c amiflop: use separate gendisks for Amiga vs MS-DOS mode 2020-11-16 08:14:30 -07:00
ataflop.c ataflop: use a separate gendisk for each media format 2020-11-16 08:14:31 -07:00
brd.c brd: use __register_blkdev to allocate devices on demand 2020-11-16 08:14:30 -07:00
cryptoloop.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 30 2019-05-24 17:27:10 +02:00
floppy.c floppy: use a separate gendisk for each media format 2020-11-16 08:14:30 -07:00
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
loop.c loop: use __register_blkdev to allocate devices on demand 2020-11-16 08:14:30 -07:00
loop.h block/loop: Use global lock for ioctl() operation. 2018-11-08 06:30:11 -07:00
Makefile block/rnbd: include client and server modules into kernel compilation 2020-05-17 18:57:17 -03:00
nbd.c nbd: fix a block_device refcount leak in nbd_release 2020-11-10 08:01:28 -07:00
null_blk_main.c null_blk: add support for max open/active zone limit for zoned devices 2020-09-29 08:12:48 -06:00
null_blk_trace.c null_blk: add tracepoint helpers for zoned mode 2020-03-27 13:39:10 -06:00
null_blk_trace.h null_blk: add tracepoint helpers for zoned mode 2020-03-27 13:39:10 -06:00
null_blk_zoned.c null_blk: Fix zone size initialization 2020-12-07 17:36:03 -07:00
null_blk.h null_blk: Fix scheduling in atomic with zoned mode 2020-11-06 09:36:42 -07:00
pktcdvd.c block: remove __blkdev_driver_ioctl 2020-11-16 08:14:29 -07:00
ps3disk.c ps3disk: use the default segment boundary 2020-05-19 00:10:35 +10:00
ps3vram.c block: move ->make_request_fn to struct block_device_operations 2020-07-01 07:27:24 -06:00
rbd_types.h libceph, rbd: replace zero-length array with flexible-array 2020-06-01 13:22:53 +02:00
rbd.c rbd: implement ->set_read_only to hook into BLKROSET processing 2020-11-16 08:14:29 -07:00
skd_main.c skd_main: remove unused including <linux/version.h> 2020-10-17 08:11:14 -06:00
skd_s1120.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 497 2019-06-19 17:09:53 +02:00
sunvdc.c compat_ioctl: block: handle cdrom compat ioctl in non-cdrom drivers 2020-01-03 09:33:15 +01:00
swim3.c swim3: use bdev_check_media_changed 2020-09-10 09:32:31 -06:00
swim_asm.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
swim.c swim: don't call blk_register_region 2020-11-16 08:14:30 -07:00
sx8.c sx8: use a per-host tag_set 2018-11-09 08:14:14 -07:00
umem.c block: move ->make_request_fn to struct block_device_operations 2020-07-01 07:27:24 -06:00
umem.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 348 2019-06-05 17:37:08 +02:00
virtio_blk.c block: add a new revalidate_disk_size helper 2020-09-02 08:00:07 -06:00
xen-blkfront.c xen-blkfront: add a parameter for disabling of persistent grants 2020-10-21 07:15:15 -05:00
xsysace.c xsysace: use platform_get_resource() and platform_get_irq_optional() 2020-10-29 08:22:33 -06:00
z2ram.c z2ram: use separate gendisk for the different modes 2020-11-16 08:14:31 -07:00