]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
NFSD enforce filehandle check for source file in COPY
authorOlga Kornievskaia <kolga@netapp.com>
Fri, 19 Aug 2022 19:16:36 +0000 (15:16 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:15 +0000 (16:19 +0200)
[ Upstream commit 754035ff79a14886e68c0c9f6fa80adb21f12b53 ]

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>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
[ cel: adjusted to apply to v5.15.y ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4proc.c

index b2e6fa962f7d97a2389dd1b1b7ffe69712047f4e..b2bfe540c1cb065e2ebe16335ca0e20339493751 100644 (file)
@@ -1760,7 +1760,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;
+                       }
                        /* ss_mnt will be unmounted by the laundromat */
                        goto do_callback;
                }