Re: [PATCH net v6 2/3] net/smc: clear the buffer pointers before registering a connection

From: Bryam Vargas

Date: Sat Nov 28 2026 - 10:54:23 EST


On Tue, 17 Nov 2026 01:06:24 +0000, netdev-bot+sashiko@xxxxxxxxxx wrote:
> - [High] This patch still leaves rmb_desc and sndbuf_desc dangling while
> the connection can be found by its token.

It does, and the cover says so: it's the first item under "Not fixed
here". A handler still runs on the released RMB if it found the
connection before smc_conn_free() unregistered it. That predates this
series, and it's the window Weiming Shi's patch [1] is about.

2/3 is for another case, the retry that registers the connection again
under a new token with the pointers from the failed attempt still set.
A CDC with the new token then finds them at any time, with no race
against the release. The note under 2/3 ("a pointer seen set stays
set") is only about the pointer not going back to NULL under the lock;
it says nothing about who owns the buffer.

> Could the pointers instead be cleared under the slock where the buffers
> are released, in smc_buf_unuse()/smc_conn_free()? Or could the token be
> unregistered before the buffers are released? Either would replace the
> clear in smc_conn_create() rather than add to it.

Not with a clear in smc_buf_unuse(): smc_conn_free() skips it when the
link group is already off its list, so the pointers stay set on that
path and a later retry registers them again. Unregistering the token
first clears nothing. Every registration goes through
smc_conn_create(), so the one clear there covers them all.

A clear in smc_conn_free() itself is different. Under the spinlock,
before the buffers are released and on every path through the
function, it would do what the clear in smc_conn_create() does. A
handler that takes the spinlock after that clear would also find NULL
at the check 2/3 adds, which closes the window above for that handler.
By inspection; not written or run.

2/3 keeps its clear in smc_conn_create(). That is enough for the retry,
and the window above is left to [1].

The two cases you list, is_reg_err set or not, are the ones the cover
measured: after the negative CONFIRM_RKEY, the descriptor is back in
the pool and the forged CDC runs on it; after a failed MR registration,
KASAN reports the UAF. Both with the retry; without one, i.e. the
window above, nothing was run here.

[1] https://lore.kernel.org/all/20261021171256.166870-2-bestswngs@xxxxxxxxx/

Thanks,
Bryam