All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andrew Stellman" <bugs@stellman-greene.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma-rc] RDMA/iwcm: Handle CLOSE before passive establishment
Date: Sun, 29 Nov 2026 00:37:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-239200@kernel.org> (raw)
In-Reply-To: <20261129001745.78689-1-bugs@stellman-greene.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] RDMA/iwcm: BUG_ON() in cm_conn_est_handler() when CLOSE
  precedes ESTABLISHED
--

commit 987e45dea45deac1e061d0f23777d7b22f32b888
Author: Andrew Stellman <astellman@stellman-greene.com>

RDMA/iwcm: Handle CLOSE before passive establishment

This commit updates cm_close_handler() to handle IW_CM_EVENT_CLOSE while an
accepted passive IWCM ID is still in IW_CM_STATE_CONN_RECV, transitioning it
to IW_CM_STATE_IDLE and notifying the consumer.

> diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
> index 94a92434063ae..554cef2469aac 100644
> --- a/drivers/infiniband/core/iwcm.c
> +++ b/drivers/infiniband/core/iwcm.c
> @@ -867,9 +867,10 @@ static void cm_conn_req_handler(struct iwcm_id_private *listen_id_priv,
>   * FPDU mode.
>   *
>   * This event can only be received in the CONN_RECV state. If the
> - * remote peer closed, the ESTABLISHED event would be received followed
> - * by the CLOSE event. If the app closes, it will block until we wake
> - * it up after processing this event.
> + * remote peer closes after establishment, ESTABLISHED is followed by
> + * CLOSE. If it closes before establishment, CLOSE can arrive first.
> + * If the app closes, it will block until we wake it up after processing
> + * this event.
>   */
>  static int cm_conn_est_handler(struct iwcm_id_private *cm_id_priv,
>  			       struct iw_cm_event *iw_event)
> @@ -974,6 +975,8 @@ static int cm_close_handler(struct iwcm_id_private *cm_id_priv,
>  	struct ib_qp *qp;
>  	unsigned long flags;
>  	int ret = 0, notify_event = 0;
> +	bool wake_connect = false;
> +
>  	spin_lock_irqsave(&cm_id_priv->lock, flags);
>  	qp = cm_id_priv->qp;
>  	cm_id_priv->qp = NULL;
> @@ -984,6 +987,15 @@ static int cm_close_handler(struct iwcm_id_private *cm_id_priv,
>  		cm_id_priv->state = IW_CM_STATE_IDLE;
>  		notify_event = 1;
>  		break;
> +	case IW_CM_STATE_CONN_RECV:
> +		/* The accepted connection closed before establishment. */
> +		cm_id_priv->state = IW_CM_STATE_IDLE;
> +		clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
> +		if (!iw_event->status)
> +			iw_event->status = -ECONNRESET;
> +		notify_event = 1;
> +		wake_connect = true;
> +		break;

[Severity: High]
Can cm_conn_est_handler() hit BUG_ON(cm_id_priv->state !=
IW_CM_STATE_CONN_RECV) if IW_CM_EVENT_CLOSE is queued before
IW_CM_EVENT_ESTABLISHED?

When a peer sends a TCP packet with FIN (such as an MPA v2 RTR frame with
TCPHDR_FIN), tcp_data_queue() runs tcp_fin() before tcp_data_ready().  In
siw, siw_cm_llp_state_change() queues SIW_CM_WORK_PEER_CLOSE without setting
qp->rx_stream.rx_suspend, while siw_rtr_data_ready() runs without
siw_cep_set_inuse() and queues IW_CM_EVENT_ESTABLISHED if rx_suspend is
still zero:

<softirq>                         siw_cm_wq / iw_cm_wq
tcp_data_queue()
  tcp_fin()
    siw_cm_llp_state_change()
      siw_cm_queue_work(...,
        SIW_CM_WORK_PEER_CLOSE)
                                  siw_cm_work_handler()
                                    siw_cm_upcall(..., IW_CM_EVENT_CLOSE)
  tcp_data_ready()
    siw_rtr_data_ready()
      if (!qp->rx_stream.rx_suspend)
        siw_cm_upcall(...,
          IW_CM_EVENT_ESTABLISHED)
                                  cm_close_handler()
                                    cm_id_priv->state = IW_CM_STATE_IDLE
                                  cm_conn_est_handler()
                                    BUG_ON(cm_id_priv->state !=
                                           IW_CM_STATE_CONN_RECV)  <-- BUG()

Since cm_close_handler() now transitions cm_id_priv->state from
IW_CM_STATE_CONN_RECV to IW_CM_STATE_IDLE without crashing, a subsequent
IW_CM_EVENT_ESTABLISHED reaches cm_conn_est_handler() in IW_CM_STATE_IDLE
(when the consumer callback does not destroy the cm_id on disconnect) and
triggers the BUG_ON().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261129001745.78689-1-bugs@stellman-greene.com?part=1

  reply	other threads:[~2026-11-29  0:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  0:17 [PATCH rdma-rc] RDMA/iwcm: Handle CLOSE before passive establishment Andrew Stellman
2026-11-29  0:37 ` sashiko-bot [this message]
2026-11-29 13:52 ` [PATCH v2 " Andrew Stellman
2026-11-29 14:07   ` sashiko-bot
2026-11-30  4:46   ` [PATCH v3 " Andrew Stellman
2026-11-30  4:55     ` sashiko-bot

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=sashiko-outbox-239200@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bugs@stellman-greene.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.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 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.