svn commit: r353602 - projects/nfsv42/sys/fs/nfsserver

Rick Macklem rmacklem at FreeBSD.org
Wed Oct 16 00:13:28 UTC 2019


Author: rmacklem
Date: Wed Oct 16 00:13:27 2019
New Revision: 353602
URL: https://svnweb.freebsd.org/changeset/base/353602

Log:
  Make the NFSv4.2 server fail Copy when from and to files are the same.
  
  The Linux copy_file_range() now allows the in_fd and out_fd to refer to
  the same file. The Linux client implements this case using read/write
  instead of the Copy operation, which is correct, since RFC-7862 does not
  allow Copy to be done with both file handles referring to the same file.
  When I looked, the server did not check for this case, so this patch adds
  code to fail the Copy when both in and out file handles refer to the same
  file.

Modified:
  projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c

Modified: projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c	Tue Oct 15 23:54:51 2019	(r353601)
+++ projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c	Wed Oct 16 00:13:27 2019	(r353602)
@@ -5217,6 +5217,11 @@ nfsrvd_copy_file_range(struct nfsrv_descript *nd, __un
 		nd->nd_repstat = NFSERR_NOTSUPP;
 		goto nfsmout;
 	}
+	if (vp == tovp) {
+		/* Copying a byte range within the same file is not allowed. */
+		nd->nd_repstat = NFSERR_INVAL;
+		goto nfsmout;
+	}
 	NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_STATEID + 3 * NFSX_HYPER +
 	    3 * NFSX_UNSIGNED);
 	instp->ls_flags = (NFSLCK_CHECK | NFSLCK_READACCESS);


More information about the svn-src-projects mailing list