linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marciniszyn, Mike" <mike.marciniszyn@cornelisnetworks.com>
To: Jia-Ju Bai <baijiaju1990@gmail.com>,
	"Dalessandro, Dennis" <dennis.dalessandro@cornelisnetworks.com>,
	"dledford@redhat.com" <dledford@redhat.com>,
	"jgg@ziepe.ca" <jgg@ziepe.ca>
Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: RE: [BUG] infiniband: hw: hfi1: possible ABBA deadlock in pio_wait() and sc_disable()
Date: Thu, 23 Sep 2021 19:06:24 +0000	[thread overview]
Message-ID: <CH0PR01MB7153B9AAF22940DBF4BCB600F2A39@CH0PR01MB7153.prod.exchangelabs.com> (raw)
In-Reply-To: <857df2fa-7d60-bff3-70f2-642201888977@gmail.com>

> 
> 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

      reply	other threads:[~2021-09-23 19:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15  9:12 Jia-Ju Bai
2021-09-23 19:06 ` Marciniszyn, Mike [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CH0PR01MB7153B9AAF22940DBF4BCB600F2A39@CH0PR01MB7153.prod.exchangelabs.com \
    --to=mike.marciniszyn@cornelisnetworks.com \
    --cc=baijiaju1990@gmail.com \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --subject='RE: [BUG] infiniband: hw: hfi1: possible ABBA deadlock in pio_wait() and sc_disable()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).