Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net/smc: fix clcsock lifetime vs asynchronous paths
@ 2026-11-20 12:45 Mahanta Jambigi
  2026-11-20 12:45 ` [PATCH net-next 1/3] net/smc: keep clcsock until socket release Mahanta Jambigi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mahanta Jambigi @ 2026-11-20 12:45 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, alibuda, dust.li,
	sidraya
  Cc: hidayath, pasic, horms, tonylu, guwen, netdev, linux-s390,
	linux-rdma, Mahanta Jambigi

The internal TCP socket (clcsock) of an SMC socket is freed by
asynchronous paths: link group termination reaches
smc_close_active_abort() and peer close reaches
smc_close_passive_work(), and both can run while the SMC socket is still
referenced by an open file descriptor. A task that uses the fd at that
moment, for example getsockopt() or a socket diag dump, then operates on
a released socket.

Free the clcsock only when no socket file can reference it: from the
socket release paths, after the socket has been unhashed, and from the
abnormal close paths once the socket has no file left. The decision is
made under the socket lock, and the accept path holds the same lock
across the accept-queue state check and sock_graft(), so a connection
that is being accepted cannot lose its clcsock to an asynchronous close.
The clcsock_release_lock is no longer needed: a socket operation on a
file is serialized with smc_release() by the file reference, and the
listen work is covered by flush_work() and cancel_work_sync() in
smc_clcsock_release().

Trade-off: with an open file, a clcsock now stays allocated after an
abnormal close until the application closes the SMC fd. The SMC
connection is already torn down and its TCP connection has been reset or
shut down; only the local TCP socket remains allocated until then.

Patch 1 makes the lifetime change and is self-contained. Patch 2 removes
the lock and the checks it made necessary, and serializes the accept
path with the asynchronous close. Patch 3 documents the invariant and
adds a destructor warning for it. The diag dump keeps its NULL check: a
socket is hashed in smc_sk_init(), before its clcsock is created.

This is hardening found by code walk, not a fix for a reported
regression, so the series targets net-next and carries no Fixes: tag.

Mahanta Jambigi (3):
  net/smc: keep clcsock until socket release
  net/smc: remove the clcsock release lock
  net/smc: document the clcsock lifetime

 net/smc/af_smc.c    | 123 +++++++++++++++---------------------------
 net/smc/smc.h       |   8 ++-
 net/smc/smc_close.c |  35 +++++++++----
 net/smc/smc_diag.c  |   3 ++
 net/smc/smc_inet.c  |   9 ++--
 5 files changed, 82 insertions(+), 96 deletions(-)

-- 
2.50.1 (Apple Git-155)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-20 12:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 12:45 [PATCH net-next 0/3] net/smc: fix clcsock lifetime vs asynchronous paths Mahanta Jambigi
2026-11-20 12:45 ` [PATCH net-next 1/3] net/smc: keep clcsock until socket release Mahanta Jambigi
2026-11-20 12:45 ` [PATCH net-next 2/3] net/smc: remove the clcsock release lock Mahanta Jambigi
2026-11-20 12:45 ` [PATCH net-next 3/3] net/smc: document the clcsock lifetime Mahanta Jambigi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox