linux-stable/drivers/block
Jens Axboe 73fd491d77 floppy: fix race condition in __floppy_read_block_0()
[ Upstream commit de7b75d82f ]

LKP recently reported a hang at bootup in the floppy code:

[  245.678853] INFO: task mount:580 blocked for more than 120 seconds.
[  245.679906]       Tainted: G                T 4.19.0-rc6-00172-ga9f38e1 #1
[  245.680959] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[  245.682181] mount           D 6372   580      1 0x00000004
[  245.683023] Call Trace:
[  245.683425]  __schedule+0x2df/0x570
[  245.683975]  schedule+0x2d/0x80
[  245.684476]  schedule_timeout+0x19d/0x330
[  245.685090]  ? wait_for_common+0xa5/0x170
[  245.685735]  wait_for_common+0xac/0x170
[  245.686339]  ? do_sched_yield+0x90/0x90
[  245.686935]  wait_for_completion+0x12/0x20
[  245.687571]  __floppy_read_block_0+0xfb/0x150
[  245.688244]  ? floppy_resume+0x40/0x40
[  245.688844]  floppy_revalidate+0x20f/0x240
[  245.689486]  check_disk_change+0x43/0x60
[  245.690087]  floppy_open+0x1ea/0x360
[  245.690653]  __blkdev_get+0xb4/0x4d0
[  245.691212]  ? blkdev_get+0x1db/0x370
[  245.691777]  blkdev_get+0x1f3/0x370
[  245.692351]  ? path_put+0x15/0x20
[  245.692871]  ? lookup_bdev+0x4b/0x90
[  245.693539]  blkdev_get_by_path+0x3d/0x80
[  245.694165]  mount_bdev+0x2a/0x190
[  245.694695]  squashfs_mount+0x10/0x20
[  245.695271]  ? squashfs_alloc_inode+0x30/0x30
[  245.695960]  mount_fs+0xf/0x90
[  245.696451]  vfs_kern_mount+0x43/0x130
[  245.697036]  do_mount+0x187/0xc40
[  245.697563]  ? memdup_user+0x28/0x50
[  245.698124]  ksys_mount+0x60/0xc0
[  245.698639]  sys_mount+0x19/0x20
[  245.699167]  do_int80_syscall_32+0x61/0x130
[  245.699813]  entry_INT80_32+0xc7/0xc7

showing that we never complete that read request. The reason is that
the completion setup is racy - it initializes the completion event
AFTER submitting the IO, which means that the IO could complete
before/during the init. If it does, we are passing garbage to
complete() and we may sleep forever waiting for the event to
occur.

Fixes: 7b7b68bba5 ("floppy: bail out in open() if drive is not responding to block0 read")
Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-12-01 09:37:32 +01:00
..
aoe drivers/block/aoe/aoedev: NULL check is not needed for mempool_destroy 2018-08-08 09:17:20 -06:00
drbd drivers/block/drbd: remove the null check for kmem_cache_destroy 2018-08-08 10:04:42 -06: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 Merge branch 'ida-4.19' of git://git.infradead.org/users/willy/linux-dax 2018-08-26 11:48:42 -07:00
xen-blkback xen/blkback: remove unused pers_gnts_lock from struct xen_blkif_ring 2018-08-27 12:12:04 -04:00
zram zram: close udev startup race condition as default groups 2018-11-21 09:19:15 +01:00
amiflop.c genhd: Rename get_disk() to get_disk_and_module() 2018-02-26 09:48:42 -07:00
ataflop.c ataflop: fix error handling during setup 2018-11-13 11:08:20 -08:00
brd.c block: brd: associate with queue until adding disk 2018-11-27 16:12:58 +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: fix race condition in __floppy_read_block_0() 2018-12-01 09:37:32 +01:00
Kconfig cdrom: Use struct scsi_sense_hdr internally 2018-08-02 15:22:39 -06:00
loop.c block/loop: mark expected switch fall-through 2018-07-09 09:07:53 -06:00
loop.h loop: remember whether sysfs_create_group() was done 2018-05-07 15:26:36 -06: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: don't allow invalid blocksize settings 2018-09-04 11:54:58 -06: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 zoned support for non-rq based operation 2018-09-12 18:21:11 -06:00
null_blk_zoned.c null_blk: fix zoned support for non-rq based operation 2018-09-12 18:21:11 -06:00
pktcdvd.c pktcdvd: fix setting of 'ret' error return for a few cases 2018-08-16 14:09:28 -06: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: support cloning across namespaces 2018-09-06 16:18:04 +02:00
rbd_types.h
skd_main.c block: skd: Use %pad printk format for dma_addr_t values 2018-07-12 15:01:28 -06:00
skd_s1120.h
sunvdc.c sunvdc: Remove VLA usage 2018-10-08 11:09:34 -07:00
swim.c swim: fix cleanup on setup error 2018-11-13 11:08:20 -08:00
swim3.c block/swim: Rename macros to avoid inconsistent inverted logic 2018-04-16 21:49:35 -06: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 block drivers/block: Use octal not symbolic permissions 2018-05-24 13:38:59 -06:00
xen-blkfront.c xen-blkfront: fix kernel panic with negotiate_mq error path 2018-11-13 11:08:53 -08:00
xsysace.c treewide: setup_timer() -> timer_setup() 2017-11-21 15:57:07 -08:00
z2ram.c treewide: kmalloc() -> kmalloc_array() 2018-06-12 16:19:22 -07:00