From: sashiko-bot@kernel.org
To: "Andrew Stellman" <bugs@stellman-greene.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH v2 rdma-rc] RDMA/iwcm: Handle CLOSE before passive establishment
Date: Sun, 29 Nov 2026 14:07:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-239681@kernel.org> (raw)
In-Reply-To: <20261129135257.80754-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() on race with
destroy_cm_id()
--
commit ca6826a9ffc5ebdff07e4969c6a9471c1e22af28
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 a
passive connection is in IW_CM_STATE_CONN_RECV, and teaches
cm_conn_est_handler() to ignore a subsequent IW_CM_EVENT_ESTABLISHED after
the ID has moved to IW_CM_STATE_IDLE.
> diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
> index 94a92434063ae..3ce99640f9ae6 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)
> @@ -885,6 +886,11 @@ static int cm_conn_est_handler(struct iwcm_id_private *cm_id_priv,
> * from a callback handler is not allowed.
> */
> clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
> + if (cm_id_priv->state == IW_CM_STATE_IDLE) {
> + /* CLOSE won the race with passive establishment. */
> + spin_unlock_irqrestore(&cm_id_priv->lock, flags);
> + return 0;
> + }
> BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_RECV);
[Severity: High]
Can cm_conn_est_handler() still hit BUG_ON() if destroy_cm_id() transitions
cm_id_priv->state from IW_CM_STATE_IDLE to IW_CM_STATE_DESTROYING before the
trailing ESTABLISHED work item takes cm_id_priv->lock?
Previously, IWCM_F_CONNECT_WAIT stayed set until cm_conn_est_handler() ran,
keeping destroy_cm_id() blocked in wait_event(). With cm_close_handler() now
clearing IWCM_F_CONNECT_WAIT and moving cm_id_priv->state to
IW_CM_STATE_IDLE, destroy_cm_id() can proceed while a queued
IW_CM_EVENT_ESTABLISHED work item is already entering cm_work_handler():
CPU0 (iwcm_wq) CPU1
cm_work_handler() [CLOSE]
cm_close_handler()
state = IW_CM_STATE_IDLE
clear_bit(IWCM_F_CONNECT_WAIT)
wake_up_all(&connect_wait)
cm_work_handler() [ESTABLISHED]
!test_bit(IWCM_F_DROP_EVENTS)
destroy_cm_id()
set_bit(IWCM_F_DROP_EVENTS)
spin_lock_irqsave(&lock)
state = IW_CM_STATE_DESTROYING
spin_unlock_irqrestore(&lock)
process_event()
cm_conn_est_handler()
spin_lock_irqsave(&lock)
state == IW_CM_STATE_IDLE (false)
BUG_ON(state != IW_CM_STATE_CONN_RECV) <-- BUG()
Checking for IW_CM_STATE_DESTROYING alongside IW_CM_STATE_IDLE (as
cm_close_handler() does) would avoid this crash.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129135257.80754-1-bugs@stellman-greene.com?part=1
prev parent reply other threads:[~2026-11-29 14:07 UTC|newest]
Thread overview: 4+ 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
2026-11-29 13:52 ` [PATCH v2 " Andrew Stellman
2026-11-29 14:07 ` sashiko-bot [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=sashiko-outbox-239681@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox