[PATCH v2 0/3] SUNRPC: do not touch a transport after publishing it

From: Piyus Kedia

Date: Sun Nov 29 2026 - 12:50:55 EST


Chuck, thanks for the review. v1 was one patch; this is the three you
asked for.

Patch 1 is the svc_addsock() fix from v1, with the Fixes: tag corrected
to b41b66d63c73, the paragraph about ed2849d3ecfa dropped, and the
comment cut to one line.

Patch 2 moves the svc_xprt_local_port() call in _svc_xprt_create() ahead
of svc_add_new_perm_xprt(). I left Cc: stable off that one, since I have
no reproducer for it - happy to add it if you would rather have it.

Patch 3 makes svc_addsock() refuse a stream socket that is not
listening, no Fixes: tag.

Patches 2 and 3 carry your Suggested-by:, since they are your
suggestions; patch 1 does not, as it predates your review.

v1: https://lore.kernel.org/linux-nfs/20261128102940.733689-1-piyus@xxxxxxxxxxx/

One thing about the ordering, from reading the two together: patch 3
closes the only route I can demonstrate for patch 1. svc_udp_init()
never sets XPT_CLOSE, so the immediate delete needs a TCP socket that is
not listening - which is exactly what patch 3 rejects. So the
reproducer has to run against patch 1 alone; with 3 applied it gets
-EINVAL and never reaches svc_addsock()'s tail.

Patch 1 still wants Cc: stable on its own, since patch 3 has no Fixes:
tag and may not travel with it. Patches 2 and 3 are by inspection; both
changed files build clean.

Piyus Kedia (3):
SUNRPC: name a listener socket before publishing its transport
SUNRPC: read a new listener's port before publishing its transport
SUNRPC: refuse a stream socket that is not listening

net/sunrpc/svc_xprt.c | 3 ++-
net/sunrpc/svcsock.c | 8 +++++++-
2 files changed, 9 insertions(+), 2 deletions(-)


base-commit: 9437ee8b6cf607e883b36e44bd755968daaebd48