public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Md Haris Iqbal <haris.iqbal@ionos.com>
Cc: linux-rdma@vger.kernel.org, bvanassche@acm.org, jgg@ziepe.ca,
	jinpu.wang@ionos.com,
	Grzegorz Prajsner <grzegorz.prajsner@ionos.com>
Subject: Re: [PATCH for-next 02/13] RDMA/rtrs-srv: Fix use-after-free during session establishment
Date: Sun, 11 Aug 2024 11:41:10 +0300	[thread overview]
Message-ID: <20240811084110.GC5925@unreal> (raw)
In-Reply-To: <20240809131538.944907-3-haris.iqbal@ionos.com>

On Fri, Aug 09, 2024 at 03:15:27PM +0200, Md Haris Iqbal wrote:
> From: Jack Wang <jinpu.wang@ionos.com>
> 
> In case of error happening during session stablishment, close_work is
> running. A new RDMA CM event may arrive since we don't destroy cm_id
> before destroying qp. To fix this, we first destroy cm_id after drain_qp,
> so no new RDMA CM event will arrive afterwards.
> 
> Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality")
> Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
> Signed-off-by: Grzegorz Prajsner <grzegorz.prajsner@ionos.com>
> Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
> ---
>  drivers/infiniband/ulp/rtrs/rtrs-srv.c | 2 +-
>  drivers/infiniband/ulp/rtrs/rtrs.c     | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
> index fb67b58a7f62..90ea25ad6720 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
> @@ -1540,6 +1540,7 @@ static void rtrs_srv_close_work(struct work_struct *work)
>  		con = to_srv_con(srv_path->s.con[i]);
>  		rdma_disconnect(con->c.cm_id);
>  		ib_drain_qp(con->c.qp);
> +		rdma_destroy_id(con->c.cm_id);
>  	}
>  
>  	/*
> @@ -1564,7 +1565,6 @@ static void rtrs_srv_close_work(struct work_struct *work)
>  			continue;
>  		con = to_srv_con(srv_path->s.con[i]);
>  		rtrs_cq_qp_destroy(&con->c);
> -		rdma_destroy_id(con->c.cm_id);
>  		kfree(con);
>  	}
>  	rtrs_ib_dev_put(srv_path->s.dev);
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c
> index 4e17d546d4cc..44167fd1c958 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs.c
> @@ -318,7 +318,7 @@ EXPORT_SYMBOL_GPL(rtrs_cq_qp_create);
>  void rtrs_cq_qp_destroy(struct rtrs_con *con)
>  {
>  	if (con->qp) {
> -		rdma_destroy_qp(con->cm_id);
> +		ib_destroy_qp(con->qp);

You created that QP with rdma_create_qp() and you should destroy it with rdma_destroy_qp().

Thanks

>  		con->qp = NULL;
>  	}
>  	destroy_cq(con);
> -- 
> 2.25.1
> 

  reply	other threads:[~2024-08-11  8:41 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09 13:15 [PATCH for-next 00/13] Misc patches for RTRS Md Haris Iqbal
2024-08-09 13:15 ` [PATCH for-next 01/13] RDMA/rtrs-srv: Make rtrs_srv_open fail if its a second call Md Haris Iqbal
2024-08-11  8:38   ` Leon Romanovsky
2024-08-12 10:16     ` Haris Iqbal
2024-08-12 10:34       ` Leon Romanovsky
2024-08-12 10:39         ` Haris Iqbal
2024-08-12 10:59           ` Leon Romanovsky
2024-08-12 11:17             ` Haris Iqbal
2024-08-12 12:15               ` Leon Romanovsky
2024-08-13  9:42                 ` Haris Iqbal
2024-08-09 13:15 ` [PATCH for-next 02/13] RDMA/rtrs-srv: Fix use-after-free during session establishment Md Haris Iqbal
2024-08-11  8:41   ` Leon Romanovsky [this message]
2024-08-12 10:52     ` Jinpu Wang
2024-08-12 11:00       ` Leon Romanovsky
2024-08-13 10:54         ` Jinpu Wang
2024-08-09 13:15 ` [PATCH for-next 03/13] RDMA/rtrs: For HB error add additional clt/srv specific logging Md Haris Iqbal
2024-08-09 13:15 ` [PATCH for-next 04/13] RDMA/rtrs-clt: Fix need_inv setting in error case Md Haris Iqbal
2024-08-09 13:15 ` [PATCH for-next 05/13] RDMA/rtrs-clt: Rate limit errors in IO path Md Haris Iqbal
2024-08-09 13:15 ` [PATCH for-next 06/13] RDMA/rtrs: Reset hb_missed_cnt after receiving other traffic from peer Md Haris Iqbal
2024-08-09 13:15 ` [PATCH for-next 07/13] RDMA/rtrs-clt: Reuse need_inval from mr Md Haris Iqbal
2024-08-09 13:15 ` [PATCH for-next 08/13] RDMA/rtrs-clt: Reset cid to con_num - 1 to stay in bounds Md Haris Iqbal
2024-08-09 13:15 ` [PATCH for-next 09/13] RDMA/rtrs-clt: Print request type for errors Md Haris Iqbal
2024-08-09 13:15 ` [PATCH for-next 10/13] RDMA/rtrs-srv: Avoid null pointer deref during path establishment Md Haris Iqbal
2024-08-09 13:15 ` [PATCH for-next 11/13] RDMA/rtrs: register ib event handler Md Haris Iqbal
2024-08-09 13:15 ` [PATCH for-next 12/13] RDMA/rtrs-clt: Do local invalidate after write io completion Md Haris Iqbal
2024-08-09 13:15 ` [PATCH for-next 13/13] RDMA/rtrs-clt: Remove an extra space Md Haris Iqbal
2024-08-11  8:43   ` Leon Romanovsky
2024-08-12  4:10     ` Jinpu Wang
2024-08-12  9:48       ` Zhu Yanjun

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=20240811084110.GC5925@unreal \
    --to=leon@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=grzegorz.prajsner@ionos.com \
    --cc=haris.iqbal@ionos.com \
    --cc=jgg@ziepe.ca \
    --cc=jinpu.wang@ionos.com \
    --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