From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 967E93264D6 for ; Sat, 5 Sep 2026 01:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788573022; cv=none; b=Vu9ArpwMGdkQY6/S8kvqx4fFRH6duP55ULBfnjZ1I74HL0ehMP+pRtAEtPi0lQijHLLktV3tB4CzGm42r2sRg97hun0tIKbqWnSkanExtnbzCv/STF7N8kUq0zN4SjcWStwyUGQukiItRDZXIN9SNlOvqTiAjU+aAQdHSPQEj8w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788573022; c=relaxed/simple; bh=gUKnNgtnQgpKqQLy02my8Q4RgJrp/cuOvdAiACtLO08=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rUO0KNezpm93/O3S1OIqEy8vxa645f2QVPjRx0zDcDR5+bLA/g3jgsdZXvcW6rdjcWC0nxu1XwggZxczynZagAxS1m/uyTSh/wpMpgPcqb9yLMW3fa7YdEIyw9WbPcPfu6KYvAG9kP4vHUeFfuZHSWiMV5jIDZQ2m2N5Z87fXcE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i79jOSty; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i79jOSty" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A31B11F00A3D; Sat, 5 Sep 2026 01:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788573021; bh=jcsWg5oRRZBAjCFNZj+oD/1TJzHT3VzlA0VXBtqiM18=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i79jOStyUDC0G4XK5XYTyayJJcAXqQ6Q45b43HiXSP8ocOaRrpMmWuB/3jdOd8XQ8 HeNXiZaiCpArtAa3Yg+0RO0aqt/7Z5+WvyWUil4SjkrMZwmB17qhTkiwz8uWv6/0wo HL73NpZTVvHsE5RpVx8bWGNzmS36Ccdegwrd3OCdjzZK8XPODoJczibh2oizdMjKna 96P+9YDM1qwNCaukAGT/2/9BNsyk7PlbK3bBP5oku5H7AAQnOO44VS1BicVcaBFuEd R46PxKVZB808H3nTWlEC2yEO20/Fqhs2M/5XU2Nj86NedI4jT/1BjykZ2Zz7VXWJMc Lj+i4SS7TUaxQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Chris Mason , Chuck Lever , Sasha Levin Subject: [PATCH 6.6.y] nfsd: size fh_verify server sockaddr slot by xpt_locallen Date: Fri, 4 Sep 2026 21:50:19 -0400 Message-ID: <20260905015019.1807496-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026090324-repaint-carpenter-eb61@gregkh> References: <2026090324-repaint-carpenter-eb61@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 d7ed49eef5911..6e57a9dba1a59 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