public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Chengfeng Ye <dg573847474@gmail.com>,
	dennis.dalessandro@cornelisnetworks.com
Cc: leon@kernel.org, dean.luick@cornelisnetworks.com,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] IB/hfi1: Fix potential deadlock on &irq_src_lock and &dd->uctxt_lock
Date: Mon, 23 Oct 2023 13:01:10 -0300	[thread overview]
Message-ID: <20231023160110.GA886087@nvidia.com> (raw)
In-Reply-To: <20230926101116.2797-1-dg573847474@gmail.com>

On Tue, Sep 26, 2023 at 10:11:16AM +0000, Chengfeng Ye wrote:
> handle_receive_interrupt_napi_sp() running inside interrupt handler
> could introduce inverse lock ordering between &dd->irq_src_lock
> and &dd->uctxt_lock, if read_mod_write() is preempted by the isr.
> 
>           [CPU0]                                        |          [CPU1]
> hfi1_ipoib_dev_open()                                   |
> --> hfi1_netdev_enable_queues()                         |
> --> enable_queues(rx)                                   |
> --> hfi1_rcvctrl()                                      |
> --> set_intr_bits()                                     |
> --> read_mod_write()                                    |
> --> spin_lock(&dd->irq_src_lock)                        |
>                                                         | hfi1_poll()
>                                                         | --> poll_next()
>                                                         | --> spin_lock_irq(&dd->uctxt_lock)
>                                                         |
>                                                         | --> hfi1_rcvctrl()
>                                                         | --> set_intr_bits()
>                                                         | --> read_mod_write()
>                                                         | --> spin_lock(&dd->irq_src_lock)
> <interrupt>                                             |
>    --> handle_receive_interrupt_napi_sp()               |
>    --> set_all_fastpath()                               |
>    --> hfi1_rcd_get_by_index()                          |
>    --> spin_lock_irqsave(&dd->uctxt_lock)               |
> 
> This flaw was found by an experimental static analysis tool I am
> developing for irq-related deadlock.
> 
> To prevent the potential deadlock, the patch use spin_lock_irqsave()
> on &dd->irq_src_lock inside read_mod_write() to prevent the possible
> deadlock scenario.
> 
> Signed-off-by: Chengfeng Ye <dg573847474@gmail.com>
> ---
>  drivers/infiniband/hw/hfi1/chip.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Dennis? This needs your ack/nack

Thanks,
Jason

  reply	other threads:[~2023-10-23 16:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26 10:11 [PATCH] IB/hfi1: Fix potential deadlock on &irq_src_lock and &dd->uctxt_lock Chengfeng Ye
2023-10-23 16:01 ` Jason Gunthorpe [this message]
2023-10-24 15:26   ` Dennis Dalessandro
2023-10-25  8:13 ` Leon Romanovsky

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=20231023160110.GA886087@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=dean.luick@cornelisnetworks.com \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=dg573847474@gmail.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox