Skip to contentSkip to conversation

NFSD: fix leak referent count of nfsd4_ssc_umount_item in nfsd4_copy

PATCH Applied Dai Ngo 3 participants 3 messages Jan 24, 2023

Subsystems (2)
lore
Share & tools
lore

Dai Ngo

author reviewer
#0 lore raw

PATCH 1/1 NFSD: fix leak referent count of nfsd4_ssc_umount_item in nfsd4_copy

The reference count of nfsd4_ssc_umount_item is not decremented on error conditions. This prevents the laundromat from unmounting the vfsmount of the source file.

This patch decrements the reference count of nfsd4_ssc_umount_item on error.

Fixes f4e44b393389 ("NFSD: delay unmount source's export after inter-server copy completed.")
---
 fs/nfsd/nfs4proc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
fs/nfsd/nfs4proc.c +8 -4
index b4e7e18e1761..889b603619c3 100644
@@ -1821,13 +1821,17 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 out:
 	return status;
 out_err:
+	if (nfsd4_ssc_is_inter(copy)) {
+		/*
+		 * Source's vfsmount of inter-copy will be unmounted
+		 * by the laundromat. Use copy instead of async_copy
+		 * since async_copy->ss_nsui might not be set yet.
+	 	*/
+		refcount_dec(&copy->ss_nsui->nsui_refcnt);
+	}
 	if (async_copy)
 		cleanup_async_copy(async_copy);
 	status = nfserrno(-ENOMEM);
-	/*
-	 * source's vfsmount of inter-copy will be unmounted
-	 * by the laundromat
-	 */
 	goto out;
 }
 
Signature · 1 line
2.9.5
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Dai Ngo

The reference count of nfsd4_ssc_umount_item is not decremented on error conditions. This prevents the laundromat from unmounting the vfsmount of the source file.

This patch decrements the reference count of nfsd4_ssc_umount_item on error.

Fixes f4e44b393389 ("NFSD: delay unmount source's export after inter-server copy completed.")
---
 fs/nfsd/nfs4proc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
fs/nfsd/nfs4proc.c +8 -0
index b4e7e18e1761..889b603619c3 100644
@@ -1821,13 +1821,17 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 out:
 	return status;
 out_err:
+	if (nfsd4_ssc_is_inter(copy)) {
+		/*
+		 * Source's vfsmount of inter-copy will be unmounted
+		 * by the laundromat. Use copy instead of async_copy
+		 * since async_copy->ss_nsui might not be set yet.
+	 	*/
+		refcount_dec(&copy->ss_nsui->nsui_refcnt);
+	}

fs/nfsd/nfs4proc.c nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, · line 1837

Quoted 10 lines
fs/nfsd/nfs4proc.c +0 -4
 	if (async_copy)
 		cleanup_async_copy(async_copy);
 	status = nfserrno(-ENOMEM);
-	/*
-	 * source's vfsmount of inter-copy will be unmounted
-	 * by the laundromat
-	 */
 	goto out;
 }
 

Looks good.

#2 lore raw
In reply to Dai Ngo
Quoted 8 lines · Dai Ngo

The reference count of nfsd4_ssc_umount_item is not decremented on error conditions. This prevents the laundromat from unmounting the vfsmount of the source file.

Quoted 5 lines

This patch decrements the reference count of nfsd4_ssc_umount_item on error.

Fixes f4e44b393389 ("NFSD: delay unmount source's export after inter-server copy completed.")

Applied to nfsd-next, thanks!

Quoted 27 lines

---
fs/nfsd/nfs4proc.c | 12 ++++++++----

1 file changed, 8 insertions(+), 4 deletions(-)
fs/nfsd/nfs4proc.c +0 -0
index b4e7e18e1761..889b603619c3 100644
@@ -1821,13 +1821,17 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,

out:

	return status;

out_err:

fs/nfsd/nfs4proc.c +8 -0
+	if (nfsd4_ssc_is_inter(copy)) {
+		/*
+		 * Source's vfsmount of inter-copy will be unmounted
+		 * by the laundromat. Use copy instead of async_copy
+		 * since async_copy->ss_nsui might not be set yet.
+	 	*/
+		refcount_dec(&copy->ss_nsui->nsui_refcnt);
+	}
	if (async_copy)
		cleanup_async_copy(async_copy);
	status = nfserrno(-ENOMEM);
fs/nfsd/nfs4proc.c +0 -4
-	/*
-	 * source's vfsmount of inter-copy will be unmounted
-	 * by the laundromat
-	 */
Quoted 6 lines
	goto out;
}
Signature · 1 line
2.9.5

--
Chuck Lever