Re: [PATCH net v2 2/2] net/smc: do not reuse the DMB of a nocopy device

From: Bryam Vargas

Date: Sat Nov 28 2026 - 10:14:13 EST


On Thu, 19 Nov 2026 12:25:12 +0530, Sidraya Jayagond wrote:
> I don't see what this branch buys us on this path. The link group is
> already off its device list here, so no new connection can join it and
> take the pooled DMB, and __smc_lgr_free_bufs() unregisters anything left
> in lgr->rmbs[] at teardown anyway, neither race from the commit
> message can happen on this path.

Agreed, the unregister buys nothing there. v3 [1] drops it and leaves
that DMB to the link group's free.

> Could you point at the path that dereferences conn->rmb_desc after
> smc_conn_free(), or drop the branch before it goes to stable?

A client that calls connect() again on the same socket. When the
handshake fails with a negative code the socket stays in SMC_INIT, and
a later connect() runs the handshake again with the same
smc_connection. conn->rmb_desc is still the first attempt's: always on
net, and with 2/2 when that attempt was freed with its link group
already off the list. If the retry then cannot allocate its RMB,
smc_conn_free() runs in the new link group with that pointer:
smc_ism_unset_conn() reads it and smc_buf_unuse() acts on it. On net
smc_buf_unuse() then zeroes the freed buffer, 65568 bytes in the test,
and clears ->used in the freed descriptor. With 2/2 and the pointer
left set it unlinks and frees the descriptor.

Measured on the loopback device with KASAN kernels and a non-blocking
connect(): the second call returns ECONNABORTED and the third runs the
handshake again. Three test knobs force the steps: the negative return
of the first attempt, its link group terminated before the attempt is
freed, and the failed RMB allocation of the retry. With
kasan_multi_shot, net gives five UAF reports, the first in
smc_ism_unset_conn(), and falls back to TCP. v1's 2/2, which had no
branch, gives five as well, the first in the same place, then a GPF in
smc_conn_free(), and close() hangs. v2 is clean, and so is v3. I
haven't found a way to get there without the knobs.

So v3 keeps only the clear on that path, WRITE_ONCE(conn->rmb_desc,
NULL), and the commit message says what the retry does with the
pointer. v6 2/3 of the CDC receive ordering series [2] clears both
pointers in smc_conn_create(), which closes the stale use on net too;
2/2's clear is there so that this path doesn't need that patch in
stable.

[1] https://lore.kernel.org/all/20261128-b4-disp-2c190c90-v3-0-c566f64196c8@xxxxxxxxx/
[2] https://lore.kernel.org/all/20261112-b4-disp-1c8d3a53-v6-0-36a38ae35021@xxxxxxxxx/

Thanks,
Bryam