From nobody Fri Aug 15 19:13:54 2025 X-Original-To: dev-commits-src-main@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 4c3WxG6yS1z64B6J; Fri, 15 Aug 2025 19:13:54 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4c3WxG4n0vz3JJr; Fri, 15 Aug 2025 19:13:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755285234; 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=xPNKA3cV/vhJrCjVs1VkINqWbWWL4cX8sIxonFIwdrg=; b=XtHN2OEPWi06OnLM0NuM5y+UwwlHFet9sMz1PPf4LvfaI2ZHPdn/768fhfzFiynhjJ9lbj nDo3dzjmbVT4emEQlQcsw0s/WmkCBajgcZyZx6+NjTAE/hjie8h2WyHK9hxCqNWXL7Jw7a skRAVl4wMbRoGAXrko4KBX5SOozlHTzcePc6uEvzFVpcWtM9DqTCZIm5ezaG6LruySWIHb WlcBX0NrhwUW909VUoUhDBnnOCIY2tFYg3nT2oIC2wiQU8uY4sAvxSbwCaLWdg8u9QT1le rAkx9SmOwvXH1Cfg+RuX1esst0+38xPSsEYKOn43bEG8yLYcYEmXrb4ce8vWAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755285234; 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=xPNKA3cV/vhJrCjVs1VkINqWbWWL4cX8sIxonFIwdrg=; b=rDE1UdCRNGmKxMGIZqYHTrYc5dOfQx2Z5QydAS00oF1vsFt/gdGbqoUnHQCzlQp/cnm9iU yQmZy/ppQgCCmdmsvUiJb+R70czIvc+4igT7RPOJQln8IOa7oh5+6YKwb63mU0inZYuVAL V+FOseVaFC3zihwn/xc05APE+JvTQxxvDSIlSpkvQ3krsY/DjbrXlchAR+LYW46tvPl15v uRU08Wyn368ZdtUEWNg3S7FAHvJj6W6zQJb37gQRqh5Cy7y8lrScN0EMDR5wAboh+znM0A lI1bkbg31foAaRuvmt6HW/AOyAgqt04c9jBusQremapnR3FbLTDiZsTiBHBg/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1755285234; a=rsa-sha256; cv=none; b=p1rkzR9Bkke8tr88X3unPnwRYyp5f9W1t/bHlTdxJ0pSbENljLzFcA2Qe1KurhqUJrPKnf 1NWuZQcv59OmsvE0LMwESRcZbV1yzKpuxxvPMmexd6KNOPC8+gD62HIWiMidf2JKrN5boH JWhQ8+PTAJcCh5sITRhVzgV8Cq49/wht58rMcBBG42rHLycSPwWOESsnJRu8KI4cna9OVz cxXPmL+t95oW48GNfcgRb2qm4bt6cLgwF1YgFvSFWmUfhiWxPoWXwrzt5EbFK5Gj6lFZAw 5s+/aIrF/grQxtzXyTVdH3e46Oc17o0eYTFhcJTEGRbpfoVdbWNiIteG2roBVQ== 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 4c3WxG4HWCzrfR; Fri, 15 Aug 2025 19:13:54 +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 57FJDs2o042196; Fri, 15 Aug 2025 19:13:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57FJDstA042193; Fri, 15 Aug 2025 19:13:54 GMT (envelope-from git) Date: Fri, 15 Aug 2025 19:13:54 GMT Message-Id: <202508151913.57FJDstA042193@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 9cd3860c10b6 - main - nfsd: Fix slow leaks of NAMEI buffers List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 9cd3860c10b6afaaaeb118dafc166ab168bc9083 Auto-Submitted: auto-generated The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=9cd3860c10b6afaaaeb118dafc166ab168bc9083 commit 9cd3860c10b6afaaaeb118dafc166ab168bc9083 Author: Rick Macklem AuthorDate: 2025-08-15 19:11:08 +0000 Commit: Rick Macklem CommitDate: 2025-08-15 19:11:08 +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") --- 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 496cac263fa0..b2966934f9b7 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -3751,6 +3751,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 36e3ce7b7142..111b0f26d0b5 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -7731,6 +7731,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"); @@ -7767,6 +7768,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; @@ -7795,6 +7797,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; @@ -8654,6 +8657,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"); @@ -8675,6 +8679,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); @@ -8717,6 +8722,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);