linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] infiniband: hw: hfi1: possible ABBA deadlock in pio_wait() and sc_disable()
@ 2021-09-15  9:12 Jia-Ju Bai
  2021-09-23 19:06 ` Marciniszyn, Mike
  0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2021-09-15  9:12 UTC (permalink / raw)
  To: mike.marciniszyn, dennis.dalessandro, dledford, jgg
  Cc: linux-rdma, linux-kernel

Hello,

My static analysis tool reports a possible ABBA deadlock in the hfi1 
driver in Linux 5.10:

sc_disable()
   write_seqlock(&sc->waitlock); --> Line 956 (Lock A)
   hfi1_qp_wakeup()
     spin_lock_irqsave(&qp->s_lock, flags); --> Line 441 (Lock B)

pio_wait()
   spin_lock_irqsave(&qp->s_lock, flags); --> Line 939 (Lock B)
   write_seqlock(&sc->waitlock); --> Line 941 (Lock A)

When sc_disable() and pio_wait() are concurrently executed, the deadlock 
can occur.

I am not quite sure whether this possible deadlock is real and how to 
fix it if it is real.
Any feedback would be appreciated, thanks :)

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>


Best wishes,
Jia-Ju Bai

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [BUG] infiniband: hw: hfi1: possible ABBA deadlock in pio_wait() and sc_disable()
  2021-09-15  9:12 [BUG] infiniband: hw: hfi1: possible ABBA deadlock in pio_wait() and sc_disable() Jia-Ju Bai
@ 2021-09-23 19:06 ` Marciniszyn, Mike
  0 siblings, 0 replies; 2+ messages in thread
From: Marciniszyn, Mike @ 2021-09-23 19:06 UTC (permalink / raw)
  To: Jia-Ju Bai, Dalessandro, Dennis, dledford, jgg; +Cc: linux-rdma, linux-kernel

> 
> Hello,
> 
> My static analysis tool reports a possible ABBA deadlock in the hfi1 driver in
> Linux 5.10:
> 
> sc_disable()
>    write_seqlock(&sc->waitlock); --> Line 956 (Lock A)
>    hfi1_qp_wakeup()
>      spin_lock_irqsave(&qp->s_lock, flags); --> Line 441 (Lock B)
> 
> pio_wait()
>    spin_lock_irqsave(&qp->s_lock, flags); --> Line 939 (Lock B)
>    write_seqlock(&sc->waitlock); --> Line 941 (Lock A)
> 
> When sc_disable() and pio_wait() are concurrently executed, the deadlock
> can occur.
> 
> I am not quite sure whether this possible deadlock is real and how to fix it if it
> is real.
> Any feedback would be appreciated, thanks :)
> 
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> 
> 
> Best wishes,
> Jia-Ju Bai

I don't think this can occur, but all other callers to hfi1_qp_wakeup() stash the waiters into an array.

I will workup a patch to move the linked list of waiters to a local, drop the lock, and process the local array of waiters.

Mike

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-23 19:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15  9:12 [BUG] infiniband: hw: hfi1: possible ABBA deadlock in pio_wait() and sc_disable() Jia-Ju Bai
2021-09-23 19:06 ` Marciniszyn, Mike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).