]> git.hungrycats.org Git - linux/commitdiff
SUNRPC: trace an accepted transport before publishing it
authorZhiling Zou <zhilinz@nebusec.ai>
Sat, 12 Sep 2026 13:56:09 +0000 (21:56 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:06:08 +0000 (12:06 -0500)
commit 06f90cf104fc21ee01e7ef1eb80e092173089b9f upstream.

svc_handle_xprt() publishes a newly accepted transport before tracing
it. svc_add_new_temp_xprt() places the transport on sv_tempsocks and
clears XPT_BUSY, so another nfsd thread can dequeue it at once. If the
peer has already closed the connection, that thread runs
svc_delete_xprt(), which drops the list reference, the only reference
the new transport holds. trace_svc_xprt_accept() then reads the
transport's addresses and network namespace from freed memory.

Before publication the accepting thread owns the transport
exclusively: XPT_BUSY is still set from svc_xprt_init() and the
transport is on no list. Emit the tracepoint there.

Fixes: 11bbb0f76e99 ("SUNRPC: Trace a few more generic svc_xprt events")
Cc: stable@vger.kernel.org
Reported-by: VEGA <vega@nebusec.ai>
Assisted-by: LLM
Signed-off-by: Zhiling Zou <zhilinz@nebusec.ai>
Link: https://patch.msgid.link/d15495bff2247e3f9d4f9ef36df8e246a3898380.1789220778.git.zhilinz@nebusec.ai
[ cel: trace before publication instead of taking an extra reference ]
Signed-off-by: Chuck Lever <cel@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sunrpc/svc_xprt.c

index 34f97009e85696efbcaeb2bf299d6fbe1779899b..4700bc84e915ce282e5911ca03ed9f606e6475e2 100644 (file)
@@ -783,8 +783,8 @@ static void svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
                newxpt = xprt->xpt_ops->xpo_accept(xprt);
                if (newxpt) {
                        newxpt->xpt_cred = get_cred(xprt->xpt_cred);
-                       svc_add_new_temp_xprt(serv, newxpt);
                        trace_svc_xprt_accept(newxpt, serv->sv_name);
+                       svc_add_new_temp_xprt(serv, newxpt);
                } else {
                        module_put(xprt->xpt_class->xcl_owner);
                }