]> www.infradead.org Git - users/willy/pagecache.git/commit
ipmi: fix potential deadlock on &kcs_bmc->lock
authorChengfeng Ye <dg573847474@gmail.com>
Tue, 27 Jun 2023 15:24:49 +0000 (15:24 +0000)
committerCorey Minyard <minyard@acm.org>
Tue, 4 Jul 2023 14:22:45 +0000 (09:22 -0500)
commitb02bb79eee074f07acdfde540f2d4fe2a04471d8
treebaef4e1d99be53c712bb1e95bff08bfb83337656
parent6cf1a126de2992b4efe1c3c4d398f8de4aed6e3f
ipmi: fix potential deadlock on &kcs_bmc->lock

As kcs_bmc_handle_event() is executed inside both a timer and a hardirq,
it should disable irq before lock acquisition otherwise deadlock could
happen if the timmer is preemtped by the irq.

Possible deadlock scenario:
aspeed_kcs_check_obe() (timer)
    -> kcs_bmc_handle_event()
    -> spin_lock(&kcs_bmc->lock)
        <irq interruption>
        -> aspeed_kcs_irq()
        -> kcs_bmc_handle_event()
        -> spin_lock(&kcs_bmc->lock) (deadlock here)

This flaw was found using an experimental static analysis tool we are
developing for irq-related deadlock.

The tentative patch fix the potential deadlock by spin_lock_irqsave()

Signed-off-by: Chengfeng Ye <dg573847474@gmail.com>
Message-Id: <20230627152449.36093-1-dg573847474@gmail.com>
Signed-off-by: Corey Minyard <minyard@acm.org>
drivers/char/ipmi/kcs_bmc.c