From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793210507; b=h3TAS6o0V18FXLh8AXFK+cAATdHfwNdmX2LXSXI7igfUhiLTbj3cMP3EZ4mn2Qzmq8zc ZV33zDaBmDfnm+j30QI0PfwpWactm3xHfvCi0GV8nOgitngMyOyiQi4k+1r49HPfatkAt DsTpvhCKct2c5mDQilCK+NKSJSTG+VNo0HuEINu9iCXaO0ilpwZKPBeAaLBjQlSjpzmkP weekhq47439P489CgmwqyrHpX1J+vQAxqMUgCGoNEcGugCSH0gOMDdpOtIfkxifIehl6R XTnfjvi+IaN98PZdAc3FGJmToCRJ14QlGE0yBsApKZQWwaOhUyWMTAOiiQunOtTYGKw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793210507; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=t3m1q4H1e5WS7A8t1hJkp8IMqPc6WAdaR4wGSbWEScY=; b=3udPwEaycIK0Wl6RwTvbrbHnvSa67Ye0Rtt/r/jL/i2R2kd+EBIzEBoKMk3pwu1RPP08 i4aSWieF+kp8+KRgBlx4r1waduw9HXLBEMkJ4n3wuzOOOcZ/Tnk5u/F01uzdBFFNqfVe8 3EG8TaO9VeMYLAB8CX5XLpdAPx15BNAWx/aiah7giTYtyVf7CnTJkaXkdprCGWZAK3YLv nLHCOMA5/3w5/5Amw5lzXa03DWjrOFWw80Yqv7UKn2qODAobe/inl9XhtUzGIeGXgJpQ4 mhlkC6+5PEYbZNc9X5ej6suWXzO8a+VZqDEzZEHpvEXasOIwPlAIehNL+OdIUCsZHPA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=s35unqzm; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCB46606A31A; Wed, 28 Oct 2026 18:01:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=s35unqzm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17D8B1F01825; Wed, 28 Oct 2026 18:01:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793210506; bh=t3m1q4H1e5WS7A8t1hJkp8IMqPc6WAdaR4wGSbWEScY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=s35unqzm60KKvGd7yjIsxUvJwncVFR9PHVTBR/cvHpkHsApJsSbRR69hzMUTHlPZ0 4kCJNTV48JrIZFNJJI1K0WNGJ4z3IoDi/wkIzsvXGRhTENvQwE5n1FF70+m55sui11 oGNu+ME733lz7QGex8r5oJC+rJVtSKupTaSFArZg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Mason , Chuck Lever , Sasha Levin Subject: [PATCH 5.15 051/571] nfsd: size fh_verify server sockaddr slot by xpt_locallen Date: Wed, 28 Oct 2026 17:53:18 +0100 Message-ID: <20261028170009.239907889@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170008.009143722@linuxfoundation.org> References: <20261028170008.009143722@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Mason [ Upstream commit 71d068490098b1d23c63b2345e40675d3a1ca763 ] The nfsd_fh_verify and nfsd_fh_verify_err tracepoints declare the server sockaddr slot sized by xpt_remotelen but fill it from xpt_local using xpt_locallen: TP_STRUCT__entry( ... __sockaddr(server, rqstp->rq_xprt->xpt_remotelen) ... ) TP_fast_assign( ... __assign_sockaddr(server, &rqstp->rq_xprt->xpt_local, rqstp->rq_xprt->xpt_locallen); ... ) When xpt_locallen exceeds xpt_remotelen, __assign_sockaddr's memcpy writes past the reserved ring-buffer slot. In the reverse direction (xpt_locallen < xpt_remotelen) the slot is oversized and the unwritten tail leaks prior ring-buffer contents to trace consumers. The write-past-end case is reachable on NFS/UDP. svc_xprt_set_remote() is only called from svc_tcp_accept() (net/sunrpc/svcsock.c) and from the RDMA connect path; svc_create_socket() for UDP calls only svc_xprt_set_local(), so xpt_remotelen stays 0 for the xprt's lifetime. Every fh_verify trace for an NFSv2/v3-over-UDP request then copies 16 or 28 bytes from xpt_local into a zero-byte slot. The other NFSD tracepoints that record the server address (NFSD_TRACE_PROC_CALL_FIELDS, NFSD_TRACE_PROC_RES_FIELDS, SVC_RQST_ENDPOINT_FIELDS) already size the server slot by xpt_locallen; nfsd_fh_verify and nfsd_fh_verify_err were the only exceptions. Fix by sizing the server slot with xpt_locallen so the declared slot matches the copy length. The client slot and its assignment already agree on xpt_remotelen and are left untouched. Fixes: 051382885552 ("NFSD: Instrument fh_verify()") Fixes: 948755efc951 ("NFSD: Replace dprintk() call site in fh_verify()") Cc: stable@vger.kernel.org Assisted-by: kres:claude-opus-4-7 Signed-off-by: Chris Mason Link: https://patch.msgid.link/20260531-nfsd-testing-v1-1-7bfa481b0540@kernel.org Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/nfsd/trace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index 91e9921db725e..bc8abf74a4cd3 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -201,7 +201,7 @@ TRACE_EVENT(nfsd_fh_verify, TP_ARGS(rqstp, fhp, type, access), TP_STRUCT__entry( __field(unsigned int, netns_ino) - __sockaddr(server, rqstp->rq_xprt->xpt_remotelen) + __sockaddr(server, rqstp->rq_xprt->xpt_locallen) __sockaddr(client, rqstp->rq_xprt->xpt_remotelen) __field(u32, xid) __field(u32, fh_hash) @@ -240,7 +240,7 @@ TRACE_EVENT_CONDITION(nfsd_fh_verify_err, TP_CONDITION(error), TP_STRUCT__entry( __field(unsigned int, netns_ino) - __sockaddr(server, rqstp->rq_xprt->xpt_remotelen) + __sockaddr(server, rqstp->rq_xprt->xpt_locallen) __sockaddr(client, rqstp->rq_xprt->xpt_remotelen) __field(u32, xid) __field(u32, fh_hash) -- 2.53.0