linux-stable/drivers/block
Chaitanya Kulkarni fb1c56d1d2 null_blk: return error for invalid zone size
[ Upstream commit e274832590 ]

In null_init_zone_dev() check if the zone size is larger than device
capacity, return error if needed.

This also fixes the following oops :-

null_blk: changed the number of conventional zones to 4294967295
BUG: kernel NULL pointer dereference, address: 0000000000000010
PGD 7d76c5067 P4D 7d76c5067 PUD 7d240c067 PMD 0
Oops: 0002 [#1] SMP NOPTI
CPU: 4 PID: 5508 Comm: nullbtests.sh Tainted: G OE 5.7.0-rc4lblk-fnext0
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba5276e4
RIP: 0010:null_init_zoned_dev+0x17a/0x27f [null_blk]
RSP: 0018:ffffc90007007e00 EFLAGS: 00010246
RAX: 0000000000000020 RBX: ffff8887fb3f3c00 RCX: 0000000000000007
RDX: 0000000000000000 RSI: ffff8887ca09d688 RDI: ffff888810fea510
RBP: 0000000000000010 R08: ffff8887ca09d688 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffff8887c26e8000
R13: ffffffffa05e9390 R14: 0000000000000000 R15: 0000000000000001
FS:  00007fcb5256f740(0000) GS:ffff888810e00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000010 CR3: 000000081e8fe000 CR4: 00000000003406e0
Call Trace:
 null_add_dev+0x534/0x71b [null_blk]
 nullb_device_power_store.cold.41+0x8/0x2e [null_blk]
 configfs_write_file+0xe6/0x150
 vfs_write+0xba/0x1e0
 ksys_write+0x5f/0xe0
 do_syscall_64+0x60/0x250
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x7fcb51c71840

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-06-07 13:17:56 +02:00
..
aoe drivers/block/aoe/aoedev: NULL check is not needed for mempool_destroy 2018-08-08 09:17:20 -06:00
drbd signal: Allow cifs and drbd to receive their terminating signals 2020-01-27 14:51:05 +01:00
mtip32xx Merge branch 'ida-4.19' of git://git.infradead.org/users/willy/linux-dax 2018-08-26 11:48:42 -07:00
paride block: paride: pd: mark expected switch fall-throughs 2018-08-09 10:17:38 -06:00
rsxx rsxx: add missed destroy_workqueue calls in remove 2019-12-13 08:51:06 +01:00
xen-blkback xen/blkback: Avoid unmapping unmapped grant pages 2020-01-09 10:19:09 +01:00
zram zram: fix race between backing_dev_show and backing_dev_store 2019-11-06 13:05:10 +01:00
amiflop.c amiflop: clean up on errors during setup 2019-12-01 09:16:25 +01:00
ataflop.c ataflop: fix error handling during setup 2018-11-13 11:08:20 -08:00
brd.c brd: check and limit max_part par 2020-02-24 08:34:53 +01:00
cryptoloop.c
DAC960.c block/DAC960.c: make some arrays static const, shrinks object size 2018-08-21 11:00:17 -06:00
DAC960.h DAC960: don't use block layer bounce buffers 2018-05-11 15:07:54 -06:00
floppy.c floppy: check FDC index for errors before assigning it 2020-02-28 16:38:45 +01:00
Kconfig cdrom: Use struct scsi_sense_hdr internally 2018-08-02 15:22:39 -06:00
loop.c loop: Better discard support for block devices 2020-04-29 16:31:13 +02:00
loop.h block/loop: Use global lock for ioctl() operation. 2019-01-22 21:40:36 +01:00
Makefile block: Rename the null_blk_mod kernel module back into null_blk 2018-07-24 09:54:36 -06:00
nbd.c nbd: add a flush_workqueue in nbd_start_device 2020-02-24 08:34:39 +01:00
null_blk.h null_blk: fix zoned support for non-rq based operation 2018-09-12 18:21:11 -06:00
null_blk_main.c null_blk: fix spurious IO errors after failed past-wp access 2020-04-17 10:48:39 +02:00
null_blk_zoned.c null_blk: return error for invalid zone size 2020-06-07 13:17:56 +02:00
pktcdvd.c pktcdvd: remove warning on attempting to register non-passthrough dev 2019-10-07 18:57:15 +02:00
ps3disk.c ps3disk: handle highmem pages 2018-05-11 15:08:03 -06:00
ps3vram.c treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
rbd.c rbd: call rbd_dev_unprobe() after unwatching and flushing notifies 2020-04-23 10:30:15 +02:00
rbd_types.h
skd_main.c skd: fixup usage of legacy IO API 2019-12-01 09:16:20 +01:00
skd_s1120.h
sunvdc.c sunvdc: Do not spin in an infinite loop when vio_ldc_send() returns EAGAIN 2019-02-12 19:47:03 +01:00
swim.c swim: fix cleanup on setup error 2018-11-13 11:08:20 -08:00
swim3.c block/swim3: Fix -EBUSY error when re-opening device after unmount 2019-02-12 19:47:18 +01:00
swim_asm.S
sx8.c block: sanitize blk_get_request calling conventions 2018-05-14 08:55:12 -06:00
umem.c block: Fix a race between the cgroup code and request queue initialization 2018-02-28 12:23:35 -07:00
umem.h
virtio_blk.c virtio-blk: handle block_device_operations callbacks after hot unplug 2020-05-20 08:18:33 +02:00
xen-blkfront.c xen/blkfront: fix memory allocation flags in blkfront_setup_indirect() 2020-04-17 10:48:53 +02:00
xsysace.c xsysace: Fix error handling in ace_setup 2019-05-08 07:21:51 +02:00
z2ram.c treewide: kmalloc() -> kmalloc_array() 2018-06-12 16:19:22 -07:00