From: Sidraya Jayagond <sidraya@linux.ibm.com>
To: hexlabsecurity@proton.me,
Mahanta Jambigi <mjambigi@linux.ibm.com>,
"D. Wythe" <alibuda@linux.alibaba.com>,
Eric Dumazet <edumazet@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
Dust Li <dust.li@linux.alibaba.com>
Cc: Stefan Raspl <raspl@linux.ibm.com>,
Simon Horman <horms@kernel.org>,
Guangguan Wang <guangguan.wang@linux.alibaba.com>,
Wen Gu <guwen@linux.alibaba.com>,
linux-s390@vger.kernel.org, linux-rdma@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Tony Lu <tonylu@linux.alibaba.com>,
Ursula Braun <ubraun@linux.ibm.com>,
Hidayath Khan <hidayath@linux.ibm.com>,
Wenjia Zhang <wenjia@linux.ibm.com>
Subject: Re: [PATCH net v2 1/6] net/smc: take the socket spinlock across the failover cursor switch
Date: Tue, 1 Dec 2026 14:17:55 +0530 [thread overview]
Message-ID: <2cc6f066-3a82-4175-be88-b1eb1984ebba@linux.ibm.com> (raw)
In-Reply-To: <20261128-b4-disp-360e65c5-v2-1-d9c05004d430@proton.me>
On 28/11/26 7:53 pm, Bryam Vargas via B4 Relay wrote:
> From: Bryam Vargas <hexlabsecurity@proton.me>
>
> smc_switch_cursor() rewrites the send cursors, sndbuf_space and
> peer_rmbe_space under send_lock only. smc_cdc_tx_handler() updates
> tx_curs_fin, local_tx_ctrl_fin and sndbuf_space, and
> smc_cdc_msg_recv_action() updates the peer's consumer cursor and
> peer_rmbe_space, under bh_lock_sock(). A CDC completion handled during a
> link switch can credit its bytes twice and leave tx_curs_fin ahead of
> tx_curs_sent, or leave tx_curs_sent and the producer cursor out of step,
> so the resend writes at the wrong RMB offset. A CDC received at the same
> time can be counted twice in peer_rmbe_space.
>
> Take bh_lock_sock() around the link change and the cursor switch, in
> the order the receive path already uses (the socket spinlock, then
> send_lock).
>
> Fixes: c6f02ebeea3a ("net/smc: switch connections to alternate link")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261029-b4-disp-33001ace-v8-0-f9bb96e17827%40proton.me?part=4
> Cc: stable@vger.kernel.org
> Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
> ---
> net/smc/smc_core.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
> index a3164201c142..73e86100e6db 100644
> --- a/net/smc/smc_core.c
> +++ b/net/smc/smc_core.c
> @@ -1171,11 +1171,18 @@ struct smc_link *smc_switch_conns(struct smc_link_group *lgr,
> /* pre-fetch buffer outside of send_lock, might sleep */
> rc = smc_cdc_get_free_slot(conn, to_lnk, &wr_buf, NULL, &pend);
> if (!rc) {
> - /* avoid race with smcr_tx_sndbuf_nonempty() */
> - spin_lock_bh(&conn->send_lock);
> + /* the CDC completion handler and the receive path
> + * update the same cursors under the socket's spinlock,
> + * smcr_tx_sndbuf_nonempty() under send_lock
> + */
> + local_bh_disable();
> + bh_lock_sock(&smc->sk);
> + spin_lock(&conn->send_lock);
> smc_switch_link_and_count(conn, to_lnk);
> rc = smc_switch_cursor(smc, pend, wr_buf);
> - spin_unlock_bh(&conn->send_lock);
> + spin_unlock(&conn->send_lock);
> + bh_unlock_sock(&smc->sk);
> + local_bh_enable();
> }
> sock_put(&smc->sk);
> if (rc)
>
The lock order matches smc_cdc_msg_recv() -> smc_tx_pending() ->
smc_tx_sndbuf_nonempty(), which takes send_lock under the socket
spinlock. I found nothing that takes them the other way round.
Reviewed-by: Sidraya Jayagond <sidraya@linux.ibm.com>
Thanks,
Sidraya
next prev parent reply other threads:[~2026-12-01 8:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 14:23 [PATCH net v2 0/6] net/smc: fix the failover cursor switch and wrap rollover Bryam Vargas via B4 Relay
2026-11-28 14:23 ` [PATCH net v2 1/6] net/smc: take the socket spinlock across the failover cursor switch Bryam Vargas via B4 Relay
2026-12-01 8:47 ` Sidraya Jayagond [this message]
2026-11-28 14:23 ` [PATCH net v2 2/6] net/smc: do not credit stale CDC completions after a link switch Bryam Vargas via B4 Relay
2026-12-01 9:00 ` Sidraya Jayagond
2026-11-28 14:23 ` [PATCH net v2 3/6] net/smc: store each cursor once in smc_switch_cursor() Bryam Vargas via B4 Relay
2026-12-01 9:03 ` Sidraya Jayagond
2026-11-28 14:23 ` [PATCH net v2 4/6] net/smc: fix the failover catch-up across the cursor wrap rollover Bryam Vargas via B4 Relay
2026-12-01 9:08 ` Sidraya Jayagond
2026-11-28 14:23 ` [PATCH net v2 5/6] net/smc: order the urgent mark " Bryam Vargas via B4 Relay
2026-12-01 8:18 ` Sidraya Jayagond
2026-11-28 14:23 ` [PATCH net v2 6/6] net/smc: update the urgent state under the socket spinlock Bryam Vargas via B4 Relay
2026-12-01 9:32 ` Sidraya Jayagond
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=2cc6f066-3a82-4175-be88-b1eb1984ebba@linux.ibm.com \
--to=sidraya@linux.ibm.com \
--cc=alibuda@linux.alibaba.com \
--cc=davem@davemloft.net \
--cc=dust.li@linux.alibaba.com \
--cc=edumazet@kernel.org \
--cc=guangguan.wang@linux.alibaba.com \
--cc=guwen@linux.alibaba.com \
--cc=hexlabsecurity@proton.me \
--cc=hidayath@linux.ibm.com \
--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=raspl@linux.ibm.com \
--cc=tonylu@linux.alibaba.com \
--cc=ubraun@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
all inboxes | Powered by JetHome®