From: Bryam Vargas <hexlabsecurity@proton.me>
To: netdev-bot+sashiko@kernel.org
Cc: Mahanta Jambigi <mjambigi@linux.ibm.com>,
Dust Li <dust.li@linux.alibaba.com>,
Eric Dumazet <edumazet@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
"D . Wythe" <alibuda@linux.alibaba.com>,
Sidraya Jayagond <sidraya@linux.ibm.com>,
Ursula Braun <ubraun@linux.ibm.com>,
Wenjia Zhang <wenjia@linux.ibm.com>,
Stefan Raspl <raspl@linux.ibm.com>,
linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
Wen Gu <guwen@linux.alibaba.com>,
Tony Lu <tonylu@linux.alibaba.com>,
Simon Horman <horms@kernel.org>,
Guangguan Wang <guangguan.wang@linux.alibaba.com>,
linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
Hidayath Khan <hidayath@linux.ibm.com>
Subject: Re: [PATCH net v9 6/6] net/smc: bound the link failover cursor advance to the send buffer
Date: Sat, 28 Nov 2026 14:49:04 +0000 [thread overview]
Message-ID: <20261128144857.1385100-1-hexlabsecurity@proton.me> (raw)
In-Reply-To: <179483404089.3136.10183363109829653220@kernel.org>
On Mon, 16 Nov 2026 13:00:40 +0000, netdev-bot+sashiko@kernel.org wrote:
> - [High] smc_switch_cursor() in net/smc/smc_core.c can now move
> tx_curs_fin backwards, so the same send-buffer bytes get credited to...
Yes. It's the "v9 only" item in the note under 6/6. An old-link
completion is credited once more if it is handled before the validation
message's completion, and the first case under 4/6 ends 1200 bytes over
the buffer where unpatched and v8 end 600 over. local_tx_ctrl_fin is
set back the same way. It needs a completion handled inside
smc_switch_cursor(). 3/6 keeps send() inside the buffer; send() can
still overwrite unsent data (by inspection).
> - [High] smc_switch_cursor() and smc_cdc_tx_handler() share no lock, and
> the patch's "set them, do not add" change does not close the race the...
It doesn't. The switch is still not serialized: the first two of your
interleavings are hook runs in the v9 notes (the first case under 4/6,
the run under 6/6); the third holds by inspection. "Set them, do not
add" only keeps the switch itself from leaving the fin cursors ahead of
the two it advanced.
The lock order you suggest is 1/6 of the failover series, now at
v2 [1]. Measured there with the sndbuf full and a handler held at its
credit while the link goes down: unpatched ends with sndbuf_space 4096
over the buffer and the reader gets wrong data; with 1/6 of [1] the
switch waits and the stream is intact. No lockdep report with v2 on a
PROVE_LOCKING build. With 2/6 of [1] a completion credits nothing if
its send was posted before the switch. A completion between the
switch's first two cursor copies, your first interleaving, was not
run with 1/6 of [1].
3/6 and 4/6 of [1] rewrite the same block and replace 6/6. The bound
is the same, tx_curs_prep; 6/6's check of cons.count against the RMBE
size is not kept. v1 of [1] capped the catch-up at the pre-failover
tx_curs_sent, which an earlier failover rewinds; with two failovers,
that cut a conforming peer's catch-up to nothing. That is the review
comment on v1's 3/4 that Sidraya asked me to fix [3], and v2 fixes
it.
> - [Medium] The permanent commit message does not mention that the patch
> adds a new route to double-crediting sndbuf_space.
Right. "Still credited more than once" reads as unchanged, and in that
ordering 6/6 credits the completion one more time than unpatched does.
Only the note and the cover say so.
> - [Medium] The new cap in smc_switch_cursor() can leave
> local_tx_ctrl.prod behind the peer's local_rx_ctrl.cons.
For a forged cons, yes. With your numbers the catch-up stops at
tx_curs_prep, prod is left at (w, 7000), smc_write_space() returns
-1000 and nothing is written until cons has moved another 1001 bytes.
That is arithmetic, not a run; the forged case in the note under 6/6
(cons one wrap ahead at count 64) has the same shape, and there nothing
is written after the switch. Unpatched puts prod on cons by advancing
tx_curs_sent and tx_curs_fin 17384 bytes with 2000 prepared, which is
what 6/6 is there to stop. Later diff_cons credits start from -1000, so
the urg_tx_pend test in smc_cdc_msg_recv_action() doesn't match even
when the peer has read everything, and the "guarantee" comment on that
credit doesn't hold. All of it on the forging peer's own connection,
and only that peer moving cons, or another failover, changes it (by
inspection).
A conforming peer's cons is never past what was written to its RMBE,
and that is never past tx_curs_prep, which a failover doesn't rewind.
So the cap doesn't cut its catch-up as long as tx_curs_fin and
local_tx_ctrl_fin are in step (by inspection). The case you call
speculative is the one where they aren't: a handler inside this switch
or an earlier one, the race in your second point.
What does cut a conforming peer's catch-up, on unpatched and v9 alike,
is smc_curs_diff(): with the peer 24576 bytes past local_tx_ctrl_fin
and a 16 KiB RMBE, [1] measured a catch-up of 8192 on unpatched and
the connection stalled with no write space (v9 by inspection); with
4/6 of [1] the catch-up was 24576.
> Pre-existing issues:
> - [High] This problem wasn't introduced by this patch, but the patch
> rewrites the very condition that depends on it.
smc_curs_comp() misorders the two cursors across the u16 wrap rollover,
in both directions; the review of v8 [2] had both. 6/6 caps what a
misordered catch-up adds and doesn't change smc_curs_comp(). 4/6 of [1]
orders the two cursors by their signed distance. Both directions are
measured there, after 1 GiB through a 16 KiB RMBE. With fin on wrap 0
and cons 12288 bytes behind it on wrap 65535, unpatched runs the
catch-up and sndbuf_space goes 20480 over; with 4/6 of [1] there is no
catch-up. Your direction with Y < X, fin at (65535, 12288) and cons at
(0, 2048): unpatched skips the catch-up, peer_rmbe_space is -10240 and
the connection stalls; with 4/6 of [1] the catch-up runs and all data
arrives. Y > X was not run; by inspection your steps hold as far as
the peer taking the producer cursor from wrap 0 back to 65535, and I
haven't followed its side further.
[1] https://lore.kernel.org/all/20261128-b4-disp-360e65c5-v2-0-d9c05004d430@proton.me/
[2] https://lore.kernel.org/all/179364387382.3131.13471253186660322977@kernel.org/
[3] https://lore.kernel.org/all/366063ac0493ac4f48df9947b98d6613@linux.ibm.com/
Thanks,
Bryam
pw-bot: cr
next prev parent reply other threads:[~2026-11-28 14:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 12:59 [PATCH net v9 0/6] net/smc: bound wire-controlled CDC cursors against the local buffers Bryam Vargas via B4 Relay
2026-11-12 12:59 ` [PATCH net v9 1/6] net/smc: bound the wire-controlled producer cursor to the RMB Bryam Vargas via B4 Relay
2026-11-12 12:59 ` [PATCH net v9 2/6] net/smc: bound the receive length " Bryam Vargas via B4 Relay
2026-11-16 13:00 ` netdev-bot+sashiko
2026-11-28 14:48 ` Bryam Vargas
2026-11-12 12:59 ` [PATCH net v9 3/6] net/smc: bound the send length to the send buffer in smc_tx_sendmsg() Bryam Vargas via B4 Relay
2026-11-16 13:00 ` netdev-bot+sashiko
2026-11-12 12:59 ` [PATCH net v9 4/6] net/smc: keep the source of an RDMA write inside the send buffer Bryam Vargas via B4 Relay
2026-11-12 12:59 ` [PATCH net v9 5/6] net/smc: keep an RDMA write inside the peer's RMBE Bryam Vargas via B4 Relay
2026-11-16 13:00 ` netdev-bot+sashiko
2026-11-12 12:59 ` [PATCH net v9 6/6] net/smc: bound the link failover cursor advance to the send buffer Bryam Vargas via B4 Relay
2026-11-16 13:00 ` netdev-bot+sashiko
2026-11-28 14:49 ` Bryam Vargas [this message]
2026-11-18 23:54 ` [PATCH net v9 0/6] net/smc: bound wire-controlled CDC cursors against the local buffers 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=20261128144857.1385100-1-hexlabsecurity@proton.me \
--to=hexlabsecurity@proton.me \
--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=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-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=raspl@linux.ibm.com \
--cc=sidraya@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