diff mbox series

[1/1] NFSD enforce filehandle check for source file in COPY

Message ID 20220819191636.68024-1-olga.kornievskaia@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/1] NFSD enforce filehandle check for source file in COPY | expand

Commit Message

Olga Kornievskaia Aug. 19, 2022, 7:16 p.m. UTC
From: Olga Kornievskaia <kolga@netapp.com>

If the passed in filehandle for the source file in the COPY operation
is not a regular file, the server MUST return NFS4ERR_WRONG_TYPE.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
---
 fs/nfsd/nfs4proc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Jeffrey Layton Aug. 19, 2022, 7:41 p.m. UTC | #1
On Fri, 2022-08-19 at 15:16 -0400, Olga Kornievskaia wrote:
> From: Olga Kornievskaia <kolga@netapp.com>
> 
> If the passed in filehandle for the source file in the COPY operation
> is not a regular file, the server MUST return NFS4ERR_WRONG_TYPE.
> 
> Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
> ---
>  fs/nfsd/nfs4proc.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index a72ab97f77ef..d8f05d96fe68 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -1768,7 +1768,13 @@ static int nfsd4_do_async_copy(void *data)
>  		filp = nfs42_ssc_open(copy->ss_mnt, &copy->c_fh,
>  				      &copy->stateid);
>  		if (IS_ERR(filp)) {
> -			nfserr = nfserr_offload_denied;
> +			switch (PTR_ERR(filp)) {
> +			case -EBADF:
> +				nfserr = nfserr_wrong_type;
> +				break;
> +			default:
> +				nfserr = nfserr_offload_denied;
> +			}
>  			nfsd4_interssc_disconnect(copy->ss_mnt);
>  			goto do_callback;
>  		}

Reviewed-by: Jeff Layton <jlayton@kernel.org>
diff mbox series

Patch

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index a72ab97f77ef..d8f05d96fe68 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1768,7 +1768,13 @@  static int nfsd4_do_async_copy(void *data)
 		filp = nfs42_ssc_open(copy->ss_mnt, &copy->c_fh,
 				      &copy->stateid);
 		if (IS_ERR(filp)) {
-			nfserr = nfserr_offload_denied;
+			switch (PTR_ERR(filp)) {
+			case -EBADF:
+				nfserr = nfserr_wrong_type;
+				break;
+			default:
+				nfserr = nfserr_offload_denied;
+			}
 			nfsd4_interssc_disconnect(copy->ss_mnt);
 			goto do_callback;
 		}