]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mISDN: hfcpci: Fix potential deadlock on &hc->lock
authorChengfeng Ye <dg573847474@gmail.com>
Thu, 27 Jul 2023 08:56:19 +0000 (08:56 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Aug 2023 13:13:50 +0000 (15:13 +0200)
commit6d8c259f482776eb64315acafcce12d59583cd1c
tree2ae7188c306a2fdb24549ac988be9fe81efcd37c
parent8dedcc6af341bfa4697bbed4bfaf2e9f4d737c66
mISDN: hfcpci: Fix potential deadlock on &hc->lock

[ Upstream commit 56c6be35fcbed54279df0a2c9e60480a61841d6f ]

As &hc->lock is acquired by both timer _hfcpci_softirq() and hardirq
hfcpci_int(), the timer should disable irq before lock acquisition
otherwise deadlock could happen if the timmer is preemtped by the hadr irq.

Possible deadlock scenario:
hfcpci_softirq() (timer)
    -> _hfcpci_softirq()
    -> spin_lock(&hc->lock);
        <irq interruption>
        -> hfcpci_int()
        -> spin_lock(&hc->lock); (deadlock here)

This flaw was found by an experimental static analysis tool I am developing
for irq-related deadlock.

The tentative patch fixes the potential deadlock by spin_lock_irq()
in timer.

Fixes: b36b654a7e82 ("mISDN: Create /sys/class/mISDN")
Signed-off-by: Chengfeng Ye <dg573847474@gmail.com>
Link: https://lore.kernel.org/r/20230727085619.7419-1-dg573847474@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/isdn/hardware/mISDN/hfcpci.c