All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Sasha Levin <sashal@kernel.org>
Cc: stable@vger.kernel.org, Chuck Lever <chuck.lever@oracle.com>,
	Jeff Layton <jlayton@kernel.org>
Subject: Re: [PATCH 6.12.y 2/2] svcrdma: Clear sc_cm_id when ADDR_CHANGE replacement fails
Date: Thu, 17 Sep 2026 12:51:34 +0100	[thread overview]
Message-ID: <2026091730-footsore-facecloth-ed76@gregkh> (raw)
In-Reply-To: <20260909003624.747050-2-sashal@kernel.org>

On Tue, Sep 08, 2026 at 08:36:24PM -0400, Sasha Levin wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
> 
> [ Upstream commit 01500306e1d50de7ca7a2cdcdfa28ac0523eb747 ]
> 
> When svc_rdma_listen_handler() handles RDMA_CM_EVENT_ADDR_CHANGE,
> it creates a replacement listener cm_id and returns 1, telling
> the CM core to destroy the old one. If the replacement allocation
> fails, sc_cm_id still points at the old cm_id that the CM core is
> about to destroy. Any subsequent dereference of sc_cm_id --
> such as svc_rdma_detach()'s rdma_disconnect() call -- is a
> use-after-free.
> 
> NULL sc_cm_id on the failure path and guard svc_rdma_detach()'s
> rdma_disconnect() call against NULL so that the listener can
> be torn down safely when the server shuts down.
> 
> Fixes: d1b586e75ec6 ("svcrdma: Handle ADDR_CHANGE CM event properly")
> Cc: stable@vger.kernel.org
> Acked-by: Jeff Layton <jlayton@kernel.org>
> Link: https://patch.msgid.link/20260527-rdma-follow-on-v1-5-1b09bd87b6cd@oracle.com
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> [ added the missing sc_cm_id NULL guard to the existing __svc_rdma_free() cleanup worker. ]
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  net/sunrpc/xprtrdma/svc_rdma_transport.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> index c8d994272f6f0..aa02c47ae5734 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> @@ -311,6 +311,7 @@ static int svc_rdma_listen_handler(struct rdma_cm_id *cma_id,
>  		if (IS_ERR(listen_id)) {
>  			pr_err("Listener dead, address change failed for device %s\n",
>  				cma_id->device->name);
> +			cma_xprt->sc_cm_id = NULL;
>  		} else
>  			cma_xprt->sc_cm_id = listen_id;
>  		return 1;
> @@ -610,14 +611,20 @@ static void svc_rdma_detach(struct svc_xprt *xprt)
>  	struct svcxprt_rdma *rdma =
>  		container_of(xprt, struct svcxprt_rdma, sc_xprt);
>  
> -	rdma_disconnect(rdma->sc_cm_id);
> +	if (rdma->sc_cm_id)
> +		rdma_disconnect(rdma->sc_cm_id);
>  }
>  
>  static void __svc_rdma_free(struct work_struct *work)
>  {
>  	struct svcxprt_rdma *rdma =
>  		container_of(work, struct svcxprt_rdma, sc_work);
> -	struct ib_device *device = rdma->sc_cm_id->device;
> +	struct ib_device *device;
> +
> +	if (!rdma->sc_cm_id)
> +		goto out_free;
> +
> +	device = rdma->sc_cm_id->device;
>  
>  	/* This blocks until the Completion Queues are empty */
>  	if (rdma->sc_qp && !IS_ERR(rdma->sc_qp))
> @@ -648,6 +655,7 @@ static void __svc_rdma_free(struct work_struct *work)
>  
>  	if (!test_bit(XPT_LISTENER, &rdma->sc_xprt.xpt_flags))
>  		rpcrdma_rn_unregister(device, &rdma->sc_rn);
> +out_free:
>  	kfree(rdma);
>  }
>  
> -- 
> 2.53.0
> 
> 

does not apply :(

      reply	other threads:[~2026-09-17 11:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 14:09 FAILED: patch "[PATCH] svcrdma: Clear sc_cm_id when ADDR_CHANGE replacement fails" failed to apply to 6.12-stable tree gregkh
2026-09-09  0:36 ` [PATCH 6.12.y 1/2] svcrdma: Add Write chunk WRs to the RPC's Send WR chain Sasha Levin
2026-09-09  0:36   ` [PATCH 6.12.y 2/2] svcrdma: Clear sc_cm_id when ADDR_CHANGE replacement fails Sasha Levin
2026-09-17 11:51     ` Greg KH [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=2026091730-footsore-facecloth-ed76@gregkh \
    --to=greg@kroah.com \
    --cc=chuck.lever@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.