mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Deepanshu Kartikey <kartikey406@gmail.com>
Cc: jgg@ziepe.ca, metze@samba.org, stfrench@microsoft.com,
	xiongweimin@kylinos.cn, yanjun.zhu@linux.dev, ammrat13@gmail.com,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+6699995b421c8ec7d2fe@syzkaller.appspotmail.com
Subject: Re: [PATCH] RDMA/cma: Don't warn when device removal races with rdma_resolve_addr()
Date: Wed, 4 Nov 2026 10:00:45 +0200	[thread overview]
Message-ID: <20261104080045.GM264423@unreal> (raw)
In-Reply-To: <20261101105615.20253-1-kartikey406@gmail.com>

On Sun, Nov 01, 2026 at 04:26:15PM +0530, Deepanshu Kartikey wrote:
> rdma_resolve_addr() on an unbound ID (RDMA_CM_IDLE) first binds it with
> cma_bind_addr() and then moves it from RDMA_CM_ADDR_BOUND to
> RDMA_CM_ADDR_QUERY with a second cma_comp_exch(). These are two
> separate steps. Once the ID is bound it is attached to the device, so
> cma_send_device_removal_put() can find it and set RDMA_CM_DEVICE_REMOVAL
> before the second step runs. The exchange then fails and hits the
> WARN_ON() added by the commit below.
> 
> syzbot triggers this with RDS over rxe, where rds_connect_worker()
> calls rdma_resolve_addr() while the rxe device is being deleted:
> 
>   WARNING: drivers/infiniband/core/cma.c:4120 at resolve_prepare_src
>   Call Trace:
>    rdma_resolve_addr
>    rds_ib_conn_path_connect
>    rds_connect_worker

Please never trim kernel dump stack and add full splat.

> 
> This is a valid race and not a kernel bug. If removal wins before the
> bind, cma_bind_addr() already fails and the error is returned to the
> caller, and err_state in the same function already ignores a failed
> state exchange. The caller gets -EINVAL, and RDS destroys the ID on any
> error from rdma_resolve_addr(), so nothing is leaked.

Why is this a valid race? The expectation is that when a device is removed,
the ib_client is notified first and then deleted. RDS should stop all
communication with the underlying device so it can be unregistered cleanly.

> 
> Drop the WARN_ON() and keep returning -EINVAL, and document in a comment
> that the state may change because of device removal.

I think that it is not correct and the issue is in RDS.

Thanks

> 
> Reported-by: syzbot+6699995b421c8ec7d2fe@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=6699995b421c8ec7d2fe
> Fixes: 732d41c545bb ("RDMA/cma: Make the locking for automatic state transition more clear")
> Tested-by: syzbot+6699995b421c8ec7d2fe@syzkaller.appspotmail.com
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> ---
>  drivers/infiniband/core/cma.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 337a49d1acf7..46741c1fd34b 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -4117,8 +4117,8 @@ static int resolve_prepare_src(struct rdma_id_private *id_priv,
>  		ret = cma_bind_addr(&id_priv->id, src_addr, dst_addr);
>  		if (ret)
>  			return ret;
> -		if (WARN_ON(!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND,
> -					   RDMA_CM_ADDR_QUERY)))
> +		if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND,
> +				   RDMA_CM_ADDR_QUERY))
>  			return -EINVAL;
>  
>  	} else {
> -- 
> 2.43.0
> 

      parent reply	other threads:[~2026-11-04  8:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01 10:56 Deepanshu Kartikey
2026-11-01 20:26 ` Zhu Yanjun
2026-11-02 10:08   ` Deepanshu Kartikey
2026-11-03  2:49     ` Zhu Yanjun
2026-11-04  8:00 ` Leon Romanovsky [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=20261104080045.GM264423@unreal \
    --to=leon@kernel.org \
    --cc=ammrat13@gmail.com \
    --cc=jgg@ziepe.ca \
    --cc=kartikey406@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=metze@samba.org \
    --cc=stfrench@microsoft.com \
    --cc=syzbot+6699995b421c8ec7d2fe@syzkaller.appspotmail.com \
    --cc=xiongweimin@kylinos.cn \
    --cc=yanjun.zhu@linux.dev \
    /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®