Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 May 2017 19:50:35 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r317973 - stable/11/sys/fs/nfsclient
Message-ID:  <201705081950.v48JoZbI007515@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Mon May  8 19:50:35 2017
New Revision: 317973
URL: https://svnweb.freebsd.org/changeset/base/317973

Log:
  MFC: r317296
  Fix some krpc leaks for the NFSv4.1/pNFS client.
  
  The NFSv4.1/pNFS client wasn't doing a newnfs_disconnect() call for the
  connection to the Data Server (DS) under some circumstances. The main
  effect of this was a leak of malloc'd structures in the krpc. This patch
  adds the newnfs_disconnect() calls to fix this.
  Detected during recent testing against the pNFS server under development.

Modified:
  stable/11/sys/fs/nfsclient/nfs_clrpcops.c
  stable/11/sys/fs/nfsclient/nfs_clvfsops.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- stable/11/sys/fs/nfsclient/nfs_clrpcops.c	Mon May  8 19:46:33 2017	(r317972)
+++ stable/11/sys/fs/nfsclient/nfs_clrpcops.c	Mon May  8 19:50:35 2017	(r317973)
@@ -5399,10 +5399,13 @@ nfsrpc_fillsa(struct nfsmount *nmp, stru
 	NFSCL_DEBUG(3, "DS connect=%d\n", error);
 
 	/* Now, do the exchangeid and create session. */
-	if (error == 0)
+	if (error == 0) {
 		error = nfsrpc_exchangeid(nmp, clp, nrp, NFSV4EXCH_USEPNFSDS,
 		    &dsp, nrp->nr_cred, p);
-	NFSCL_DEBUG(3, "DS exchangeid=%d\n", error);
+		NFSCL_DEBUG(3, "DS exchangeid=%d\n", error);
+		if (error != 0)
+			newnfs_disconnect(nrp);
+	}
 	if (error == 0) {
 		dsp->nfsclds_sockp = nrp;
 		NFSLOCKMNT(nmp);
@@ -5445,8 +5448,10 @@ nfsrpc_fillsa(struct nfsmount *nmp, stru
 		TAILQ_INSERT_TAIL(&nmp->nm_sess, dsp, nfsclds_list);
 		NFSUNLOCKMNT(nmp);
 		*dspp = dsp;
-	} else if (dsp != NULL)
+	} else if (dsp != NULL) {
+		newnfs_disconnect(nrp);
 		nfscl_freenfsclds(dsp);
+	}
 	return (error);
 }
 

Modified: stable/11/sys/fs/nfsclient/nfs_clvfsops.c
==============================================================================
--- stable/11/sys/fs/nfsclient/nfs_clvfsops.c	Mon May  8 19:46:33 2017	(r317972)
+++ stable/11/sys/fs/nfsclient/nfs_clvfsops.c	Mon May  8 19:50:35 2017	(r317973)
@@ -1643,8 +1643,12 @@ bad:
 		NFSUNLOCKCLSTATE();
 		free(nmp->nm_clp, M_NFSCLCLIENT);
 	}
-	TAILQ_FOREACH_SAFE(dsp, &nmp->nm_sess, nfsclds_list, tdsp)
+	TAILQ_FOREACH_SAFE(dsp, &nmp->nm_sess, nfsclds_list, tdsp) {
+		if (dsp != TAILQ_FIRST(&nmp->nm_sess) &&
+		    dsp->nfsclds_sockp != NULL)
+			newnfs_disconnect(dsp->nfsclds_sockp);
 		nfscl_freenfsclds(dsp);
+	}
 	FREE(nmp, M_NEWNFSMNT);
 	FREE(nam, M_SONAME);
 	return (error);
@@ -1709,8 +1713,12 @@ nfs_unmount(struct mount *mp, int mntfla
 		AUTH_DESTROY(nmp->nm_sockreq.nr_auth);
 	mtx_destroy(&nmp->nm_sockreq.nr_mtx);
 	mtx_destroy(&nmp->nm_mtx);
-	TAILQ_FOREACH_SAFE(dsp, &nmp->nm_sess, nfsclds_list, tdsp)
+	TAILQ_FOREACH_SAFE(dsp, &nmp->nm_sess, nfsclds_list, tdsp) {
+		if (dsp != TAILQ_FIRST(&nmp->nm_sess) &&
+		    dsp->nfsclds_sockp != NULL)
+			newnfs_disconnect(dsp->nfsclds_sockp);
 		nfscl_freenfsclds(dsp);
+	}
 	FREE(nmp, M_NEWNFSMNT);
 out:
 	return (error);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705081950.v48JoZbI007515>