From nobody Fri Aug 29 03:23:08 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cCk9m2Swbz65wkv; Fri, 29 Aug 2025 03:23:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cCk9m1sbxz3bLv; Fri, 29 Aug 2025 03:23:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756437788; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yqAXrybVOA2us87laJIdut6oKdePRbL5YpRVEaNvavs=; b=DE+MZN0ojwUQ1Vvm4eqNvnNkAI/TPwusQShmzouFaye+GNFF3a3rBO3EqjeHaXdPusqWeW fEBuC1qnZ22sil5nqpi8hTGbAZEAsk4N1Vt8My+CqvWHCs0rzVd+b8RfhGGVRuHY65IplJ khYbToRr3qkz2NxCArNalNw8WPCXWQTdjPry+W6RwoalZc3o4SfUbzEAu5vWqdX06sXlNb dkrP2Pj3Xo2xRUa/zw/X8HJjKvpHZOBn5xxsmFvOoSNcs9uOXHatDj9xuilk2czWt8WDSP JocpW/VNdVhPoBnahNBqSs2b1SDgR5sRqd4YcqrM9WPeVm0K6a9zJHe0iOEcIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756437788; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yqAXrybVOA2us87laJIdut6oKdePRbL5YpRVEaNvavs=; b=x4DoN0bq5H2TTCwua6jTczOWIpIFyuGJvjG13LdR2d5DpO3566yd1jmPqirvaeoxwMxlih VkATSYuvppD+juKnU5q1bceYC/OWzBzySsqVU9+kZoU/dsYWTv8HqrkbYX/VB+iFZqLo8x SQmjxFF3NCX3d0FegFw4r31h+GMll93NqO2JV160IuHGA7X3D9O55ZKu5pAN7dgh0fqMub LJL85ybVBgqqw7Wm3Plf3HQdToh8dbJ/U3IK1unPqR/XLPKICpgz8iAWS9PaOijtiALWbV TOhmWX8jCbQ5oavMcU0CcDC10HYvjwsJTij8q+5+YOMVdFXaGY82j71hA7dDew== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1756437788; a=rsa-sha256; cv=none; b=gf9kGci2V3O/Lo+uW3JR2XmvdZTHx/eIykWmuP5pwfjI8ffY3wQFnKRAwc3kTisXkPk+Qv 0aOc82nJAv5CbZ3cL9G0CU15XdiSfgxwpcipepuQPBPrgAEpivPbvipayJda63swPnFDJr ujoITMrEYk9BZHESuyj7m5bRpR5biNCt5NKN2+5fn4NFMSQr9rQGO1E3rJPFvFzfXN8z4W UPVM2ppNUXVnszAW5Pj9l8PqkIiOEk8OoNofkYIatsrBHzW+oeFt0rrZREGZYyltse0+Hn 8Casx6Ti5Njxu5v7NGSuwwYgIDyT+cP6TNhKgL+4FGMSiW9i+559P0pMgVu15w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cCk9m1FdPz6qn; Fri, 29 Aug 2025 03:23:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 57T3N8gQ065676; Fri, 29 Aug 2025 03:23:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57T3N8nJ065673; Fri, 29 Aug 2025 03:23:08 GMT (envelope-from git) Date: Fri, 29 Aug 2025 03:23:08 GMT Message-Id: <202508290323.57T3N8nJ065673@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: b06973a2f2a8 - stable/14 - nfsd: Fix slow leaks of NAMEI buffers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: b06973a2f2a8854b4803c9a4d00dc0482be8f268 Auto-Submitted: auto-generated The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=b06973a2f2a8854b4803c9a4d00dc0482be8f268 commit b06973a2f2a8854b4803c9a4d00dc0482be8f268 Author: Rick Macklem AuthorDate: 2025-08-15 19:11:08 +0000 Commit: Rick Macklem CommitDate: 2025-08-29 03:20:15 +0000 nfsd: Fix slow leaks of NAMEI buffers Commit 5b5b7e2ca2fa changed namei()s behaviour such that it does not free the NAMEI buffer unless returning an error. The nfsd was not fixed for this. Fortunately, the only leak would be one NAMEI buffer each time mountd(8) reloads the exports. (There were also leaks in the pNFS server configuration, but almost no one uses it.) This patch fixes the leaks by adding NDFREE_PNBUF() macros in the appropriate places. MFC after: 2 weeks Discussed with: kib Fixes: 5b5b7e2ca2fa ("vfs: always retain path buffer after lookup") (cherry picked from commit 9cd3860c10b6afaaaeb118dafc166ab168bc9083) --- sys/fs/nfsserver/nfs_nfsdport.c | 1 + sys/fs/nfsserver/nfs_nfsdstate.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index a4a729613038..c22d06ef0aeb 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -3589,6 +3589,7 @@ nfsrv_v4rootexport(void *argp, struct ucred *cred, struct thread *p) NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, nfsexargp->fspec); if ((error = namei(&nd)) != 0) goto out; + NDFREE_PNBUF(&nd); error = nfsvno_getfh(nd.ni_vp, &fh, p); vrele(nd.ni_vp); if (!error) { diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 0f556adb697b..cca977b31e8e 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -7724,6 +7724,7 @@ nfsrv_setdsserver(char *dspathp, char *mdspathp, NFSPROC_T *p, NFSD_DEBUG(4, "lookup=%d\n", error); if (error != 0) return (error); + NDFREE_PNBUF(&nd); if (nd.ni_vp->v_type != VDIR) { vput(nd.ni_vp); NFSD_DEBUG(4, "dspath not dir\n"); @@ -7760,6 +7761,7 @@ nfsrv_setdsserver(char *dspathp, char *mdspathp, NFSPROC_T *p, NFSD_DEBUG(4, "dsdirpath=%s lookup=%d\n", dsdirpath, error); if (error != 0) break; + NDFREE_PNBUF(&nd); if (nd.ni_vp->v_type != VDIR) { vput(nd.ni_vp); error = ENOTDIR; @@ -7788,6 +7790,7 @@ nfsrv_setdsserver(char *dspathp, char *mdspathp, NFSPROC_T *p, NFSD_DEBUG(4, "mds lookup=%d\n", error); if (error != 0) goto out; + NDFREE_PNBUF(&nd); if (nd.ni_vp->v_type != VDIR) { vput(nd.ni_vp); error = ENOTDIR; @@ -8647,6 +8650,7 @@ nfsrv_mdscopymr(char *mdspathp, char *dspathp, char *curdspathp, char *buf, NFSD_DEBUG(4, "lookup=%d\n", error); if (error != 0) return (error); + NDFREE_PNBUF(&nd); if (nd.ni_vp->v_type != VREG) { vput(nd.ni_vp); NFSD_DEBUG(4, "mdspath not reg\n"); @@ -8668,6 +8672,7 @@ nfsrv_mdscopymr(char *mdspathp, char *dspathp, char *curdspathp, char *buf, vput(vp); return (error); } + NDFREE_PNBUF(&nd); if (nd.ni_vp->v_type != VDIR) { vput(nd.ni_vp); vput(vp); @@ -8710,6 +8715,7 @@ nfsrv_mdscopymr(char *mdspathp, char *dspathp, char *curdspathp, char *buf, vput(curvp); return (error); } + NDFREE_PNBUF(&nd); if (nd.ni_vp->v_type != VDIR || nd.ni_vp == curvp) { vput(nd.ni_vp); vput(vp);