Date: Wed, 16 Oct 2019 00:13:27 +0000 (UTC) From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r353602 - projects/nfsv42/sys/fs/nfsserver Message-ID: <201910160013.x9G0DRXV060334@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910160013.x9G0DRXV060334>