2023-01-24 05:34:50

by Dai Ngo

[permalink] [raw]
Subject: [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.")
Signed-off-by: Dai Ngo <[email protected]>
---
fs/nfsd/nfs4proc.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index b4e7e18e1761..889b603619c3 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -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;
}

--
2.9.5



2023-01-24 11:48:31

by Jeff Layton

[permalink] [raw]
Subject: Re: [PATCH 1/1] NFSD: fix leak referent count of nfsd4_ssc_umount_item in nfsd4_copy

On Mon, 2023-01-23 at 21:34 -0800, Dai Ngo wrote:
> 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.")
> Signed-off-by: Dai Ngo <[email protected]>
> ---
> fs/nfsd/nfs4proc.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index b4e7e18e1761..889b603619c3 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -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;
> }
>

Looks good.

Reviewed-by: Jeff Layton <[email protected]>

2023-01-24 16:55:15

by Chuck Lever III

[permalink] [raw]
Subject: Re: [PATCH 1/1] NFSD: fix leak referent count of nfsd4_ssc_umount_item in nfsd4_copy



> On Jan 24, 2023, at 12:34 AM, Dai Ngo <[email protected]> wrote:
>
> 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.")
> Signed-off-by: Dai Ngo <[email protected]>

Applied to nfsd-next, thanks!


> ---
> fs/nfsd/nfs4proc.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index b4e7e18e1761..889b603619c3 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -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;
> }
>
> --
> 2.9.5
>

--
Chuck Lever