mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Yuehong Wu <wuyuehong@cmss.chinamobile.com>
Cc: linux-rdma@vger.kernel.org, Leon Romanovsky <leon@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 rdma-rc] RDMA/ucma: free a queued CONNECT_REQUEST with its new context
Date: Sat, 14 Nov 2026 20:16:33 -0400	[thread overview]
Message-ID: <20261115001633.GG2532299@ziepe.ca> (raw)
In-Reply-To: <20261112-ucma-conn-req-ctx-v2-1-yuehongwu@cmss.chinamobile.com>

On Thu, Nov 12, 2026 at 09:42:00AM +0800, Yuehong Wu wrote:
> --- a/drivers/infiniband/core/ucma.c
> +++ b/drivers/infiniband/core/ucma.c
> @@ -534,8 +534,25 @@ static int ucma_cleanup_ctx_events(struct ucma_context *ctx)
>  	/* Cleanup events not yet reported to the user.*/
>  	mutex_lock(&ctx->file->mut);
>  	list_for_each_entry_safe(uevent, tmp, &ctx->file->event_list, list) {
> -		if (uevent->ctx != ctx)
> +		/*
> +		 * A CONNECT_REQUEST that has not been delivered to user
> +		 * space is queued on the listening context but stores a
> +		 * pointer to the new connection context.  The new context is
> +		 * live in ctx_table before the event is queued, so it can be
> +		 * destroyed before the event is fetched; the event can then
> +		 * no longer be acted upon.  Drop it instead of leaving a
> +		 * dangling conn_req_ctx in the event list.
> +		 */
> +		if (uevent->ctx != ctx) {
> +			if (uevent->resp.event == RDMA_CM_EVENT_CONNECT_REQUEST &&
> +			    uevent->conn_req_ctx == ctx) {
> +				list_del(&uevent->list);
> +				/* Return the slot taken for this request. */
> +				atomic_inc(&uevent->ctx->backlog);
> +				kfree(uevent);
> +			}

The seems like it defeats the cleanup process, or moves the race
around.

I would expect the solution to this problem to hold some kind of
reference while the uevent is alive.

Or perhaps blocking ucma_destory_id while the event still exists.

Jason

      reply	other threads:[~2026-11-15  0:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  1:42 Yuehong Wu
2026-11-15  0:16 ` Jason Gunthorpe [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=20261115001633.GG2532299@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=wuyuehong@cmss.chinamobile.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

all inboxes | Powered by JetHome®