From owner-svn-src-projects@freebsd.org Wed Oct 16 00:13:28 2019 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 12CAF157A97 for ; Wed, 16 Oct 2019 00:13:28 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46tCSR6YpLz41jq; Wed, 16 Oct 2019 00:13:27 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C4A6226988; Wed, 16 Oct 2019 00:13:27 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9G0DRGi060335; Wed, 16 Oct 2019 00:13:27 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9G0DRXV060334; Wed, 16 Oct 2019 00:13:27 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201910160013.x9G0DRXV060334@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Wed, 16 Oct 2019 00:13:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r353602 - projects/nfsv42/sys/fs/nfsserver X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/nfsv42/sys/fs/nfsserver X-SVN-Commit-Revision: 353602 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Oct 2019 00:13:28 -0000 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);