From: sashiko-bot@kernel.org
To: "Piyus Kedia" <piyus@iiitd.ac.in>
Cc: linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
"Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH net v2 1/2] net/smc: bound the failover cursor catch-up by what is outstanding
Date: Tue, 24 Nov 2026 13:53:43 +0000 [thread overview]
Message-ID: <sashiko-outbox-231270@kernel.org> (raw)
In-Reply-To: <20261123135327.3953509-1-piyus@iiitd.ac.in>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] net/smc: smc_switch_cursor() bounds catch-up by prepared
instead of sent bytes
- [High] net/smc: smc_switch_cursor() clamp leaves local_tx_ctrl.prod
behind cons
--
commit d641bcdb06babb4611de33b1b2a3ed34727ace6d
Author: Piyus Kedia <piyus@iiitd.ac.in>
net/smc: bound the failover cursor catch-up by what is outstanding
This commit bounds the cursor catch-up diff in smc_switch_cursor() by
conn->sndbuf_desc->len - atomic_read(&conn->sndbuf_space) so a peer's
consumer cursor cannot credit conn->sndbuf_space past the send buffer size.
Link: https://lore.kernel.org/all/20261122053223.2497832-2-piyus@iiitd.ac.in/
> diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
> index a3164201c1420..436a702f3d8de 100644
> --- a/net/smc/smc_core.c
> +++ b/net/smc/smc_core.c
> @@ -1057,6 +1057,7 @@ static int smc_switch_cursor(struct smc_sock *smc, struct smc_cdc_tx_pend *pend,
> union smc_host_cursor cons, fin;
> int rc = 0;
> int diff;
> + int sent;
>
> smc_curs_copy(&conn->tx_curs_sent, &conn->tx_curs_fin, conn);
> smc_curs_copy(&fin, &conn->local_tx_ctrl_fin, conn);
> @@ -1069,6 +1070,16 @@ static int smc_switch_cursor(struct smc_sock *smc, struct smc_cdc_tx_pend *pend,
> * fin above, so now prod is smaller than cons. Fix that.
> */
> diff = smc_curs_diff(conn->peer_rmbe_size, &fin, &cons);
> + /* The peer's consumer cursor is taken as it arrives, so this
> + * difference is a value the peer chose. An honest peer cannot
> + * have consumed more than this side has outstanding, so bound
> + * the catch-up by that: sndbuf_space then keeps the invariant
> + * the tx path relies on, and the cursors advanced below stay
> + * within the send buffer.
> + */
> + sent = conn->sndbuf_desc->len - atomic_read(&conn->sndbuf_space);
[Severity: High]
Does conn->sndbuf_desc->len - atomic_read(&conn->sndbuf_space) measure all
prepared bytes in the send buffer (tx_curs_prep - tx_curs_fin) rather than the
unconfirmed bytes actually transmitted to the peer RMBE (tx_curs_sent -
tx_curs_fin before tx_curs_sent is overwritten above)?
When prepared but unsent data sits between tx_curs_sent and tx_curs_prep (for
example due to corking, autocorking, or a full peer RMBE), advancing
tx_curs_sent and tx_curs_fin up to sent skips over unsent payload in sndbuf
and credits sndbuf_space for data that was never put on the wire. Also, when
conn->sndbuf_desc->len > conn->peer_rmbe_size, sent can exceed
conn->peer_rmbe_size, allowing smc_curs_add(conn->peer_rmbe_size, ...) below
(which subtracts peer_rmbe_size only once) to leave local_tx_ctrl.prod.count
at or above conn->peer_rmbe_size. Finally, advancing tx_curs_fin past the old
tx_curs_sent moves it ahead of any in-flight cdcpend->cursor on the old link
(which is drained via smc_wr_tx_wait_no_pending_sends() only after
smc_switch_conns() returns), so a completing CQE on the old link in
smc_cdc_tx_handler() either computes a wrapped diff or rewinds tx_curs_fin and
lets the new link's validation CQE double-credit sndbuf_space above
sndbuf_desc->len.
Computing the bound from smc_curs_diff(conn->sndbuf_desc->len,
&conn->tx_curs_fin, &conn->tx_curs_sent) before overwriting conn->tx_curs_sent
would limit the catch-up to bytes actually sent on the old link.
> + diff = min_t(int, diff, max_t(int, sent, 0));
[Severity: High]
When this clamp reduces diff below smc_curs_diff(conn->peer_rmbe_size, &fin,
&cons), does leaving conn->local_rx_ctrl.cons unclamped leave
conn->local_tx_ctrl.prod behind conn->local_rx_ctrl.cons after this block?
smc_switch_cursor() resets conn->local_tx_ctrl.prod to fin and relies on
adding diff to bring prod up to cons, then immediately updates peer_rmbe_space
via smc_write_space():
net/smc/smc_core.c:smc_write_space() {
...
smc_curs_copy(&prod, &conn->local_tx_ctrl.prod, conn);
smc_curs_copy(&cons, &conn->local_rx_ctrl.cons, conn);
/* determine rx_buf space */
space = buffer_len - smc_curs_diff(buffer_len, &cons, &prod);
return space;
}
Both smc_curs_diff(buffer_len, &cons, &prod) and smc_tx_rdma_writes() assume
cons <= prod. If prod < cons across a wrap boundary (prod.wrap != cons.wrap),
smc_curs_diff() takes the old->wrap != new->wrap branch and returns
(buffer_len - cons.count) + prod.count; when prod.count > cons.count that
exceeds buffer_len and makes peer_rmbe_space negative, and when
peer_rmbe_space > 0 smc_tx_rdma_writes() sees prod.wrap != cons.wrap, skips
clamping dst_len to conn->peer_rmbe_size - prod.count, and can RDMA-write past
the end of the peer RMBE.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123135327.3953509-1-piyus@iiitd.ac.in?part=1
next prev parent reply other threads:[~2026-11-24 13:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 13:53 [PATCH net v2 1/2] net/smc: bound the failover cursor catch-up by what is outstanding Piyus Kedia
2026-11-23 13:53 ` [PATCH net v2 2/2] net/smc: bound the DMB-nocopy send-buffer credit as well Piyus Kedia
2026-11-24 13:53 ` sashiko-bot
2026-11-24 14:14 ` netdev-bot+sashiko
2026-11-24 13:53 ` sashiko-bot [this message]
2026-11-24 14:14 ` [PATCH net v2 1/2] net/smc: bound the failover cursor catch-up by what is outstanding netdev-bot+sashiko
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-231270@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=piyus@iiitd.ac.in \
--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