From: Tony Lu <tonylu@linux.alibaba.com>
To: hexlabsecurity@proton.me
Cc: Dust Li <dust.li@linux.alibaba.com>,
Sidraya Jayagond <sidraya@linux.ibm.com>,
Paolo Abeni <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Wenjia Zhang <wenjia@linux.ibm.com>,
"D. Wythe" <alibuda@linux.alibaba.com>,
Mahanta Jambigi <mjambigi@linux.ibm.com>,
Wen Gu <guwen@linux.alibaba.com>,
Eric Dumazet <edumazet@google.com>,
linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org,
netdev@vger.kernel.org, Simon Horman <horms@kernel.org>,
linux-s390@vger.kernel.org
Subject: Re: [PATCH net v2 1/2] net/smc: unregister the connection before draining the rx tasklet
Date: Thu, 13 Aug 2026 15:29:00 +0800 [thread overview]
Message-ID: <an1yPOa-GoiXLvH5@TONYMAC-ALIBABA.local> (raw)
In-Reply-To: <20260808-b4-disp-22f119e6-v2-1-61647601a6f3@proton.me>
On Sat, Aug 08, 2026 at 02:21:23AM -0500, Bryam Vargas via B4 Relay wrote:
> From: Bryam Vargas <hexlabsecurity@proton.me>
>
> smc_conn_free() calls smc_ism_unset_conn() only while the link group is
> still on its device list, and never sets conn->killed.
> smc_lgr_terminate_sched() unlinks the group immediately and defers killing
> its connections to a work item, so a connection freed in that window keeps
> its smcd->conn[] slot with both gates in smcd_handle_irq() open, and the
> device can re-arm the receive tasklet after tasklet_kill() has returned. On
> the DMB-nocopy path the ghost send buffer is freed right after that drain,
> so the re-armed tasklet dereferences it.
>
> Unregister unconditionally and drain before the detach at both teardown
> sites, mirroring rmb_desc, which smc_buf_unuse() releases after the drain.
> Clear conn->sndbuf_desc before freeing it as well, so a reader that samples
> the pointer cannot get one that is already freed.
>
> Fixes: ae2be35cbed2 ("net/smc: {at|de}tach sndbuf to peer DMB if supported")
> Cc: stable@vger.kernel.org
> Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
Reviewed-by: Tony Lu <tonylu@linux.alibaba.com>
> ---
> net/smc/smc_core.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
> index b4208cb186c5..181647982490 100644
> --- a/net/smc/smc_core.c
> +++ b/net/smc/smc_core.c
> @@ -1209,14 +1209,16 @@ static void smcd_buf_detach(struct smc_connection *conn)
> {
> struct smcd_dev *smcd = conn->lgr->smcd;
> u64 peer_token = conn->peer_token;
> + struct smc_buf_desc *buf_desc;
>
> if (!conn->sndbuf_desc)
> return;
>
> smc_ism_detach_dmb(smcd, peer_token);
>
> - kfree(conn->sndbuf_desc);
> + buf_desc = conn->sndbuf_desc;
> conn->sndbuf_desc = NULL;
> + kfree(buf_desc);
> }
>
> static void smc_buf_unuse(struct smc_connection *conn,
> @@ -1268,11 +1270,10 @@ void smc_conn_free(struct smc_connection *conn)
> goto lgr_put;
>
> if (lgr->is_smcd) {
> - if (!list_empty(&lgr->list))
> - smc_ism_unset_conn(conn);
> + smc_ism_unset_conn(conn);
> + tasklet_kill(&conn->rx_tsklet);
> if (smc_ism_support_dmb_nocopy(lgr->smcd))
> smcd_buf_detach(conn);
> - tasklet_kill(&conn->rx_tsklet);
> } else {
> smc_cdc_wait_pend_tx_wr(conn);
> if (current_work() != &conn->abort_work)
> @@ -1525,12 +1526,12 @@ static void smc_conn_kill(struct smc_connection *conn, bool soft)
> smc_sk_wake_ups(smc);
> if (conn->lgr->is_smcd) {
> smc_ism_unset_conn(conn);
> - if (smc_ism_support_dmb_nocopy(conn->lgr->smcd))
> - smcd_buf_detach(conn);
> if (soft)
> tasklet_kill(&conn->rx_tsklet);
> else
> tasklet_unlock_wait(&conn->rx_tsklet);
> + if (smc_ism_support_dmb_nocopy(conn->lgr->smcd))
> + smcd_buf_detach(conn);
> } else {
> smc_cdc_wait_pend_tx_wr(conn);
> }
>
> --
> 2.55.0
>
next prev parent reply other threads:[~2026-08-13 7:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-08 7:21 [PATCH net v2 0/2] net/smc: close the SMC-D teardown window around the ghost send buffer Bryam Vargas via B4 Relay
2026-08-08 7:21 ` [PATCH net v2 1/2] net/smc: unregister the connection before draining the rx tasklet Bryam Vargas via B4 Relay
2026-08-13 5:47 ` Sidraya Jayagond
2026-08-13 7:29 ` Tony Lu [this message]
2026-08-08 7:21 ` [PATCH net v2 2/2] net/smc: do not dereference an unset send buffer on the SMC-D teardown path Bryam Vargas via B4 Relay
2026-08-13 5:47 ` Sidraya Jayagond
2026-08-13 7:29 ` Tony Lu
2026-08-13 0:10 ` [PATCH net v2 0/2] net/smc: close the SMC-D teardown window around the ghost send buffer Jakub Kicinski
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=an1yPOa-GoiXLvH5@TONYMAC-ALIBABA.local \
--to=tonylu@linux.alibaba.com \
--cc=alibuda@linux.alibaba.com \
--cc=davem@davemloft.net \
--cc=dust.li@linux.alibaba.com \
--cc=edumazet@google.com \
--cc=guwen@linux.alibaba.com \
--cc=hexlabsecurity@proton.me \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjambigi@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sidraya@linux.ibm.com \
--cc=wenjia@linux.ibm.com \
/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