linux-stable/drivers/block
Shigeru Yoshida 62006a72b0 nbd: Fix hung when signal interrupts nbd_start_device_ioctl()
[ Upstream commit 1de7c3cf48 ]

syzbot reported hung task [1].  The following program is a simplified
version of the reproducer:

int main(void)
{
	int sv[2], fd;

	if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) < 0)
		return 1;
	if ((fd = open("/dev/nbd0", 0)) < 0)
		return 1;
	if (ioctl(fd, NBD_SET_SIZE_BLOCKS, 0x81) < 0)
		return 1;
	if (ioctl(fd, NBD_SET_SOCK, sv[0]) < 0)
		return 1;
	if (ioctl(fd, NBD_DO_IT) < 0)
		return 1;
	return 0;
}

When signal interrupt nbd_start_device_ioctl() waiting the condition
atomic_read(&config->recv_threads) == 0, the task can hung because it
waits the completion of the inflight IOs.

This patch fixes the issue by clearing queue, not just shutdown, when
signal interrupt nbd_start_device_ioctl().

Link: https://syzkaller.appspot.com/bug?id=7d89a3ffacd2b83fdd39549bc4d8e0a89ef21239 [1]
Reported-by: syzbot+38e6c55d4969a14c1534@syzkaller.appspotmail.com
Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20220907163502.577561-1-syoshida@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-10-24 09:58:24 +02:00
..
aoe aoe: Avoid flush_scheduled_work() usage 2022-05-01 06:41:41 -06:00
drbd drbd: Return true/false (not 1/0) from bool functions 2022-04-17 19:54:24 -06:00
mtip32xx block: simplify disk shutdown 2022-09-28 11:32:01 +02:00
null_blk null_blk: fix ida error handling in null_add_dev() 2022-08-17 15:15:42 +02:00
paride Char/Misc and other driver changes for 5.17-rc1 2022-01-14 16:02:28 +01:00
rnbd block: simplify disk shutdown 2022-09-28 11:32:01 +02:00
xen-blkback xen-blkback: Advertise feature-persistent as user requested 2022-09-08 11:24:04 +02:00
zram Revert "zram: remove double compression logic" 2022-08-31 17:18:17 +02:00
Kconfig floppy: disable FDRAWCMD by default 2022-04-27 09:41:54 -07:00
Makefile block: remove the rsxx driver 2021-12-16 10:57:04 -07:00
amiflop.c block: remove the ->rq_disk field in struct request 2021-11-29 06:41:29 -07:00
ataflop.c block: simplify disk shutdown 2022-09-28 11:32:01 +02:00
brd.c brd: remove brd_devices_mutex mutex 2022-01-17 07:19:40 -07:00
floppy.c floppy: use a statically allocated error counter 2022-05-08 10:01:48 -07:00
loop.c block: simplify disk shutdown 2022-09-28 11:32:01 +02:00
n64cart.c n64cart: convert bi_disk to bi_bdev->bd_disk fix build 2022-03-21 06:34:45 -06:00
nbd.c nbd: Fix hung when signal interrupts nbd_start_device_ioctl() 2022-10-24 09:58:24 +02:00
pktcdvd.c for-5.19/block-2022-05-22 2022-05-23 13:56:39 -07:00
ps3disk.c ps3disk: add error handling support for add_disk() 2021-10-30 11:03:37 -06:00
ps3vram.c block: remove GENHD_FL_EXT_DEVT 2021-11-29 06:38:35 -07:00
rbd.c A big pile of assorted fixes and improvements for the filesystem with 2022-06-02 08:59:39 -07:00
rbd_types.h
sunvdc.c block: remove genhd.h 2022-02-02 07:49:59 -07:00
swim.c block: remove GENHD_FL_EXT_DEVT 2021-11-29 06:38:35 -07:00
swim3.c block: remove GENHD_FL_EXT_DEVT 2021-11-29 06:38:35 -07:00
swim_asm.S
sx8.c block: simplify disk shutdown 2022-09-28 11:32:01 +02:00
virtio_blk.c virtio-blk: Fix WARN_ON_ONCE in virtio_queue_rq() 2022-10-05 10:40:53 +02:00
xen-blkfront.c xen-blkfront: Cache feature_persistent value before advertisement 2022-09-08 11:24:04 +02:00
z2ram.c block: simplify disk shutdown 2022-09-28 11:32:01 +02:00