mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Allison Henderson <achender@kernel.org>
To: Aohan Mei <ljp1205831794@gmail.com>, netdev@vger.kernel.org
Cc: linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com,
	 linux-kernel@vger.kernel.org,
	Jason Xing <kerneljasonxing@gmail.com>,
	Aohan Mei <henrymei@tencent.com>,
	TencentOS Corvus AI <corvus@tencent.com>,
	 stable@vger.kernel.org
Subject: Re: [PATCH net] net: rds: fix uninitialized trans dereference in CM event handler
Date: Mon, 24 Aug 2026 11:56:35 -0700	[thread overview]
Message-ID: <c4c495fbc56774c012aebb5979dd72070e4a1c9d.camel@kernel.org> (raw)
In-Reply-To: <20260824111701.2979194-1-ljp1205831794@gmail.com>

On Mon, 2026-08-24 at 19:17 +0800, Aohan Mei wrote:
> From: Aohan Mei <henrymei@tencent.com>
> 
> rds_rdma_cm_event_handler_cmn() assigns trans only when the RDMA
> device is an InfiniBand CA (RDMA_NODE_IB_CA).  On any other device
> type, e.g. an iWARP RNIC such as siw, trans stays uninitialized, but
> the event switch dereferences it: unconditionally in the
> RDMA_CM_EVENT_CONNECT_REQUEST case via trans->cm_handle_connect(),
> and (with a connection context) in the ROUTE_RESOLVED and
> ESTABLISHED cases.
> 
> An RDS listener on an iWARP device therefore crashes the kernel as
> soon as a connect request arrives: with CONFIG_INIT_STACK_ALL_ZERO
> the wild load becomes a NULL dereference at offset 0xa0
> (&trans->cm_handle_connect) in the iw_cm_wq workqueue.
> 
> GCC masks the bug in default builds by folding the uninitialized
> load into &rds_ib_transport; Clang-built kernels take the real
> uninitialized path and oops.
> 
> Reject events that arrive on device types without an RDS transport:
> initialize trans to NULL and bail out before the event switch when
> no transport matched.
> 
> Fixes: dcdede0406d3 ("RDS: Drop stale iWARP RDMA transport")
> Reported-by: TencentOS Corvus AI <corvus@tencent.com>
> Cc: stable@vger.kernel.org
> Assisted-by: CodeBuddy:Kimi-K3
> Signed-off-by: Aohan Mei <henrymei@tencent.com>
> 
> 

Hi Aohan,

Thanks for catching this.  A few comments below:

> ---
>  net/rds/rdma_transport.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/net/rds/rdma_transport.c b/net/rds/rdma_transport.c
> index b15cf316b23a..ad9244a09848 100644
> --- a/net/rds/rdma_transport.c
> +++ b/net/rds/rdma_transport.c
> @@ -52,7 +52,7 @@ static int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
>  {
>  	/* this can be null in the listening path */
>  	struct rds_connection *conn = cm_id->context;
> -	struct rds_transport *trans;
> +	struct rds_transport *trans = NULL;
>  	int ret = 0;
>  	int *err;
>  	u8 len;
> @@ -80,6 +80,14 @@ static int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
>  		}
>  	}
>  
> +	/* No RDS transport exists for this device type (e.g. iWARP RNIC),
> +	 * so trans was never assigned; reject instead of dereferencing it.
> +	 */
> +	if (!trans) {
> +		ret = 1;
> +		goto out;
> +	}
> +

Support for iWarp was removed in dcdede0406d30e1 and this function only supports ib.  So we should probably just enforce
the ib transport:

	if (cm_id->device->node_type != RDMA_NODE_IB_CA) {
		ret = 1;
		goto out;
	}

Then we can just initialize trans to &rds_ib_transport at the top, and remove the conditional assignment that appears a
few lines up from here. 

Thanks!
Allison


>  	switch (event->event) {
>  	case RDMA_CM_EVENT_CONNECT_REQUEST:
>  		ret = trans->cm_handle_connect(cm_id, event, isv6);


      reply	other threads:[~2026-08-24 18:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 11:17 Aohan Mei
2026-08-24 18:56 ` Allison Henderson [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=c4c495fbc56774c012aebb5979dd72070e4a1c9d.camel@kernel.org \
    --to=achender@kernel.org \
    --cc=corvus@tencent.com \
    --cc=henrymei@tencent.com \
    --cc=kerneljasonxing@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=ljp1205831794@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=rds-devel@oss.oracle.com \
    --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 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®