linux-brain/drivers/uio
Jia-Ju Bai ea6b7b1d58 uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol()
[ Upstream commit b74351287d4bd90636c3f48bc188c2f53824c2d4 ]

The driver may sleep while holding a spinlock.
The function call path (from bottom to top) in Linux 4.19 is:

kernel/irq/manage.c, 523:
	synchronize_irq in disable_irq
drivers/uio/uio_dmem_genirq.c, 140:
	disable_irq in uio_dmem_genirq_irqcontrol
drivers/uio/uio_dmem_genirq.c, 134:
	_raw_spin_lock_irqsave in uio_dmem_genirq_irqcontrol

synchronize_irq() can sleep at runtime.

To fix this bug, disable_irq() is called without holding the spinlock.

This bug is found by a static analysis tool STCheck written by myself.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Link: https://lore.kernel.org/r/20191218094405.6009-1-baijiaju1990@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-02-24 08:34:37 +01:00
..
Kconfig uio-hv-generic: new userspace i/o driver for VMBus 2016-12-06 11:52:49 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
uio_aec.c
uio_cif.c uio: add SPDX license tags 2018-07-21 15:41:20 +02:00
uio_dmem_genirq.c uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol() 2020-02-24 08:34:37 +01:00
uio_fsl_elbc_gpcm.c uio: add SPDX license tags 2018-07-21 15:41:20 +02:00
uio_hv_generic.c vmbus: keep pointer to ring buffer page 2019-11-20 18:47:31 +01:00
uio_mf624.c uio_mf624: Align memory regions to page size and set correct offsets 2017-04-08 18:13:28 +02:00
uio_netx.c uio: add SPDX license tags 2018-07-21 15:41:20 +02:00
uio_pci_generic.c uio: add SPDX license tags 2018-07-21 15:41:20 +02:00
uio_pdrv_genirq.c Revert "uio: constify of_device_id array" 2015-04-03 16:04:21 +02:00
uio_pruss.c uio: pruss: fix error handling in probe 2018-08-02 10:14:26 +02:00
uio_sercos3.c uio: add SPDX license tags 2018-07-21 15:41:20 +02:00
uio.c driver: uio: fix possible use-after-free in __uio_register_device 2020-01-27 14:50:17 +01:00