linux_dsm_epyc7002/drivers/block
Pavel Skripkin 8dc3800363 block: nbd: add sanity check for first_minor
[ Upstream commit b1a811633f7321cf1ae2bb76a66805b7720e44c9 ]

Syzbot hit WARNING in internal_create_group(). The problem was in
too big disk->first_minor.

disk->first_minor is initialized by value, which comes from userspace
and there wasn't any sanity checks about value correctness. It can cause
duplicate creation of sysfs files/links, because disk->first_minor will
be passed to MKDEV() which causes truncation to byte. Since maximum
minor value is 0xff, let's check if first_minor is correct minor number.

NOTE: the root case of the reported warning was in wrong error handling
in register_disk(), but we can avoid passing knowingly wrong values to
sysfs API, because sysfs error messages can confuse users. For example:
user passed 1048576 as index, but sysfs complains about duplicate
creation of /dev/block/43:0. It's not obvious how 1048576 becomes 0.
Log and reproducer for above example can be found on syzkaller bug
report page.

Link: https://syzkaller.appspot.com/bug?id=03c2ae9146416edf811958d5fd7acfab75b143d1
Fixes: b0d9111a2d ("nbd: use an idr to keep track of nbd devices")
Reported-by: syzbot+9937dc42271cd87d4b98@syzkaller.appspotmail.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-05 19:10:20 +02: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-clt: Check the return value of the function rtrs_clt_query 2021-05-19 10:13:06 +02:00
rsxx block: rsxx: fix error return code of rsxx_pci_probe() 2021-03-17 17:06:33 +01:00
xen-blkback xen-blkback: fix compatibility bug with single page rings 2021-05-14 09:50:21 +02:00
zram zram: fix return value on writeback_store 2021-03-17 17:06:34 +01:00
amiflop.c amiflop: use bdev_check_media_change 2020-09-10 09:32:30 -06:00
ataflop.c ataflop: use bdev_check_media_change 2020-09-10 09:32:30 -06:00
brd.c bdi: remove BDI_CAP_SYNCHRONOUS_IO 2020-09-24 13:43:39 -06:00
cryptoloop.c cryptoloop: add a deprecation warning 2024-07-05 19:05:03 +02:00
floppy.c Revert "floppy: reintroduce O_NDELAY fix" 2024-07-05 19:02:15 +02:00
Kconfig cryptoloop: add a deprecation warning 2024-07-05 19:05:03 +02:00
loop.c loop: fix I/O error on fsync() in detached loop devices 2021-07-19 09:44:55 +02: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 block: nbd: add sanity check for first_minor 2024-07-05 19:10:20 +02:00
null_blk_main.c null_blk: fix command timeout completion handling 2021-04-16 11:43:21 +02: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 drivers/block/null_blk/main: Fix a double free in null_init. 2021-05-14 09:50:28 +02:00
null_blk.h null_blk: fix command timeout completion handling 2021-04-16 11:43:21 +02:00
pktcdvd.c pktcdvd: use blkdev_get_by_dev instead of open coding it 2020-09-23 10:43:19 -06: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: always kick acquire on "acquired" and "released" notifications 2021-07-28 14:35:46 +02: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: simplify media change handling 2020-09-10 09:32:30 -06:00
sx8.c sx8: use a per-host tag_set 2018-11-09 08:14:14 -07:00
umem.c umem: fix error return code in mm_pci_probe() 2021-03-30 14:31:50 +02:00
umem.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 348 2019-06-05 17:37:08 +02:00
virtio_blk.c virtio-blk: Fix memory leak among suspend/resume procedure 2021-07-20 16:05:49 +02:00
xen-blkfront.c xen-blkfront: allow discard-* nodes to be optional 2021-02-03 23:28:44 +01:00
xsysace.c xsysace: use platform_get_resource() and platform_get_irq_optional() 2020-10-29 08:22:33 -06:00
z2ram.c mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00