linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	Leon Romanovsky <leon@kernel.org>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
	Damien Le Moal <dlemoal@kernel.org>
Subject: Re: [PATCH v2] RDMA/cma: prevent rdma id destroy during cma_iw_handler
Date: Tue, 13 Jun 2023 10:30:37 -0300	[thread overview]
Message-ID: <ZIhvfdVOMsN2cXEX@ziepe.ca> (raw)
In-Reply-To: <3x4kcccwy5s2yhni5t26brhgejj24kxyk7bnlabp5zw2js26eb@kjwyilm5d4wc>

On Tue, Jun 13, 2023 at 01:43:43AM +0000, Shinichiro Kawasaki wrote:
> > I think there is likely some much larger issue with the IW CM if the
> > cm_id can be destroyed while the iwcm_id is in use? It is weird that
> > there are two id memories for this :\
> 
> My understanding about the call chain to rdma id destroy is as follows. I guess
> _destory_id calls iw_destory_cm_id before destroying the rdma id, but not sure
> why it does not wait for cm_id deref by cm_work_handler.
> 
> nvme_rdma_teardown_io_queueus
>  nvme_rdma_stop_io_queues -> chained to cma_iw_handler
>  nvme_rdma_free_io_queues
>   nvme_rdma_free_queue
>    rdma_destroy_id
>     mutex_lock(&id_priv->handler_mutex)
>     destroy_id_handler_unlock
>      mutex_unlock(&id_priv->handler_mutex)
>      _destory_id
>        iw_destroy_cm_id
>        wait_for_completiion(&id_priv->comp)
>        kfree(id_priv)

Once a destroy_cm_id() has returned that layer is no longer
permitted to run or be running in its handlers. The iw cm is broken if
it allows this, and that is the cause of the bug.

Taking more refs within handlers that are already not allowed to be
running is just racy.

Jason

  parent reply	other threads:[~2023-06-13 13:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12  5:42 [PATCH v2] RDMA/cma: prevent rdma id destroy during cma_iw_handler Shin'ichiro Kawasaki
2023-06-12  7:13 ` Leon Romanovsky
2023-06-12 14:18 ` Jason Gunthorpe
2023-06-13  1:43   ` Shinichiro Kawasaki
2023-06-13  6:47     ` Shinichiro Kawasaki
2023-06-13 13:30     ` Jason Gunthorpe [this message]
2023-06-13 18:07       ` Leon Romanovsky
2023-06-14  7:53         ` Shinichiro Kawasaki
2023-06-14 17:36           ` Jason Gunthorpe
2023-06-15  0:45             ` Shinichiro Kawasaki
2023-09-05  0:39               ` Shinichiro Kawasaki
2023-09-06  8:54                 ` Daniel Wagner
2023-09-06 11:31                   ` Shinichiro Kawasaki
2023-09-07  7:47                     ` Yi Zhang
2023-09-07 16:17                       ` Jason Gunthorpe
2023-09-08  7:18                       ` Hannes Reinecke
2023-09-08  8:33                         ` Yi Zhang

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=ZIhvfdVOMsN2cXEX@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=dlemoal@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=shinichiro.kawasaki@wdc.com \
    /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;
as well as URLs for NNTP newsgroup(s).