Re: [PATCH net] net/smc: bound a send by the send buffer, not by the peer's credit
From: Piyus Kedia
Date: Mon Nov 23 2026 - 08:54:07 EST
Thank you for the review. Every point was checked against net.git main at
af6737b90668 before answering, and three of them changed the patch rather
than its description, so v2 is a two-patch series rather than a reworded
version of this one. It is posted as a separate thread:
[PATCH net v2 1/2] net/smc: bound the failover cursor catch-up by what is
outstanding
[PATCH net v2 2/2] net/smc: bound the DMB-nocopy send-buffer credit as well
There is no cover letter; the v2 changelog is under the --- line of 1/2,
with a Link: back to this thread.
Point by point.
1. The threat model in this patch is wrong
> Is this threat model accurate for the path named here?
> With real ISM hardware this credit branch never runs. With loopback-ism,
> both ends are the same kernel, so in-kernel SMC code writes the consumer
> cursor, not a remote party.
> Would it be more accurate to describe the nocopy part as hardening?
You are right, and this is the part of the review I am most grateful for.
smc_ism_support_dmb_nocopy() needs a dibs device providing
support_mmapped_rdmb(), and the only provider in the tree is
drivers/dibs/dibs_loopback.c, where both ends of the connection are the same
kernel. The subject of my bug report naming "SMC-D DMB-nocopy" as the attack
was therefore wrong. In v2 that path is patch 2/2 and is described as
hardening.
2. smc_switch_cursor() is the writer a peer can actually reach
> Is the nocopy path the only place that credits sndbuf_space from a peer
> cursor? smc_switch_cursor() in net/smc/smc_core.c runs on SMC-R link
> failover [...] Nothing bounds diff from above.
No, it is not the only place, and smc_switch_cursor() is the one that matters.
diff comes from conn->local_rx_ctrl.cons, smc_cdc_cursor_to_host() rejects
only a cursor that moves backward inside one wrap, and the chain you name is
in the tree as described:
smc_llc_rx_delete_link()
smc_llc_process_cli_delete_link() net/smc/smc_llc.c:1620
smc_switch_conns() net/smc/smc_llc.c:1657
smc_switch_cursor() net/smc/smc_core.c:1053
That is patch 1/2 of v2, and it carries Cc: stable.
Being straight about the evidence: we have no multi-link SMC-R group with two
RDMA devices here, so this route is from reading the code, not from a run.
The overflow itself was reproduced through the other writer, on loopback-ism
with the consumer cursor forged by a debug patch. If a link group that
reaches smc_switch_cursor() cannot in practice carry a forged cursor, I would
be glad to be told.
3. The clamp did not restore the invariant, so it is gone
> Does this clamp bound the send by the send buffer, as the subject says?
> Each memcpy_from_msg() now stays inside the buffer, but sndbuf_space itself
> is still uncapped.
> Would the credit need to be capped where it is added [...] Without that, the
> invariant isn't restored.
Agreed on all of it. With copylen clamped and the credit still inflated, the
producer never reaches smc_tx_wait(), later writes can overwrite data that has
not been sent while sendmsg() reports success, smc_tx_prepared_sends() and
to_send in smc_tx_rdma_writes() misreport pending data, and SIOCOUTQ returns a
negative queue length.
v2 bounds the credit at both sites where it is added and does not touch
smc_tx.c at all. The bound is what this side has outstanding,
sndbuf_desc->len minus the current sndbuf_space: a peer cannot have consumed
more than that, so it is a no-op for a correct peer rather than a cap chosen
by guesswork. With it, 0 <= sndbuf_space <= sndbuf_desc->len holds again, so
the two comments you noted as becoming false are true once more and need no
change.
4. smc_curs_add() subtracting the size only once
> smc_curs_add() subtracts the size only once. For a large enough diff, could
> tx_curs_sent.count therefore stay at or above sndbuf_desc->len?
It could, and smc_tx_rdma_writes() then uses that count as a source offset -
a second fault, which the clamp in this patch did nothing about. Bounding the
difference fixes it as well: value < sndbuf_desc->len always, so one
subtraction is enough. Patch 1/2 says so in its commit message.
In 2/2 the related assignment
smc_curs_copy(&conn->tx_curs_fin, &conn->local_rx_ctrl.cons, conn);
is replaced by advancing tx_curs_fin by the bounded difference, so a reported
cursor is never installed as a send-buffer cursor. For a cursor that reflects
real consumption the two are the same value.
5. Fixes: tags and Cc: stable
> Should this carry Fixes: tags and Cc: stable?
Yes. Both are in v2, each confirmed by blaming the atomic_add() in question:
1/2 Fixes: c6f02ebeea3a ("net/smc: switch connections to alternate link")
2/2 Fixes: cc0ab806fc52 ("net/smc: adapt cursor update when sndbuf and peer
DMB are merged")
Cc: stable is on 1/2 only. 2/2 is unreachable on any device in the tree, so
by stable-kernel-rules it is not a bug that bothers anyone; say the word if you
would rather have it there too.
6. The receive side
> This isn't a bug introduced by this patch, but the receive side appears to
> have the same unclamped second chunk. [...] The commit message points to
> "net/smc: validate the peer's CDC cursors against our own buffers" for the
> receive side. That validation isn't in this tree.
Correct, and my commit message implied it was applied, which it is not - it is
a separate patch posted on its own. The two are independent and either can go
in first. Worth being precise about why both are needed: that patch bounds the
peer's cons by conn->peer_rmbe_size, which keeps the cursor inside the peer's
RMBE but still permits "I consumed more than you sent", so it does not bound
the credit this series bounds; and this series does nothing for the receive
path.
Found by AI-driven fuzzing built on top of syzkaller, with the analysis checked
by hand against the code; the v2 cover letter says which parts were reproduced
and which were only read.
Thanks again - points 3 and 4 changed the shape of the fix, not just its
wording.
Kapil Vaswani
Piyus Kedia