From nobody Tue Oct 04 00:43:22 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MhJpg4fsWz4VBZK; Tue, 4 Oct 2022 00:43:23 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MhJpf4mrBz3dfH; Tue, 4 Oct 2022 00:43:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664844202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6zZq6ckD3/vMptdzd/nca3lqQEFh6FnKRb7vkikYzrI=; b=tc42RUdgw/emgW9xhp1gyHZzTkaXw1OSYxQGLY3oE7hO6WMulzUbrNn/+0zsnUR0ML1yg2 H/oooEMphqVxBpyFI2DkAcFyfzd05USVlmjwq4eZr8Ml1Zs/vuP8nRZ1XQ2Zb2VSqTwSnv vnZB3L6zbEmrJlyVcKiGrukCsP8QvjxwNi5usqyMarD2leHtnD87i3+PwoK/Vj2giCmrEE UuMzCf6P7GnYPFu+To80u42lJltyqGFXo3NG43fmCYsFVy6HlWefkCFL2U1kXu+jjRT+nq zDA2r4Z5eFaigZNHEnPCKTLYOcJxgafnE5fLRiFo2WS1sDD909EeoSvSoioCRw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MhJpf3npVzNmD; Tue, 4 Oct 2022 00:43:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2940hMTC078335; Tue, 4 Oct 2022 00:43:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2940hMxP078334; Tue, 4 Oct 2022 00:43:22 GMT (envelope-from git) Date: Tue, 4 Oct 2022 00:43:22 GMT Message-Id: <202210040043.2940hMxP078334@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: aa4d15bb8e7a - stable/13 - nfsclient: access v_mount only after the vnode is locked List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: aa4d15bb8e7a8310cf185c71dfa6ccdc93a9136f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664844202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6zZq6ckD3/vMptdzd/nca3lqQEFh6FnKRb7vkikYzrI=; b=qStG4isD6IZn5H5AS3o4NSuIIssFrxD/dwbtF3iV5dcclWn9lNWRePsXqk51PDD+8nk8Tj i97mLfIfoBTs6tpJLzFevmQrrm1Tj+p1IIIGfxuU5n0u54SFNRODeRENUdLkct8xKdCQj0 X/3XH/LHlY+Ygc0b/wtdLCBpmPoejONGQcOk9M7HjSQptVm/5a5vDICD1HsJpnS9uLZtnL eh70GQaIZbvSPfy3HQ/3kRXhxExd5vKmOX0rw8iM7baWkiZekh+mRDdSwU6p4wDrGyVEyz +yhBfqHQfFLUQeKCvN5WUmyi2dRODs/8mv4qLUPohZ3DvD9lrogPSCuoKsE6lQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664844202; a=rsa-sha256; cv=none; b=TJseArHvgbPWY0yBh2x9lWdcE8gqKxQQN1svEgK1Qos5JX7B65s131RtOWZcWWMZystoFY MKiNtO5CnSVFiNkqlNa5QYBAuuL/W+mcErN0diUmG8BbbHubrfM+aKMjCIDP2a80YNMPzM sZSVlOxqoV4ngjBE9DT4c3zc13dfYzjxUJOo1xLDuQv2qlZfYPRlIZ2bYzxhXx1dAo5xZI gVqaifjoQXhlNv3ZMUVS0O6+4u18+9cjMgDBXlMJCWFw3YwHRMAC4V3w7d7RB956sIsL8I w7ZOxCXM9syen5mboQZH6gURrQ+i+5a3m/eMf6tv05js6Q1O9Cc+1itHXxkaYw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=aa4d15bb8e7a8310cf185c71dfa6ccdc93a9136f commit aa4d15bb8e7a8310cf185c71dfa6ccdc93a9136f Author: Konstantin Belousov AuthorDate: 2022-09-26 18:10:47 +0000 Commit: Konstantin Belousov CommitDate: 2022-10-04 00:42:56 +0000 nfsclient: access v_mount only after the vnode is locked (cherry picked from commit ab17854f974b5671b09139079d98e2068802064b) --- sys/fs/nfsclient/nfs_clvnops.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index a92875aae6ed..569327b14e41 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3805,19 +3805,13 @@ nfs_copy_file_range(struct vop_copy_file_range_args *ap) off_t inoff, outoff; bool consecutive, must_commit, tryoutcred; - ret = ret2 = 0; - nmp = VFSTONFS(invp->v_mount); - mtx_lock(&nmp->nm_mtx); /* NFSv4.2 Copy is not permitted for infile == outfile. */ - if (!NFSHASNFSV4(nmp) || nmp->nm_minorvers < NFSV42_MINORVERSION || - (nmp->nm_privflag & NFSMNTP_NOCOPY) != 0 || invp == outvp) { - mtx_unlock(&nmp->nm_mtx); - error = vn_generic_copy_file_range(ap->a_invp, ap->a_inoffp, - ap->a_outvp, ap->a_outoffp, ap->a_lenp, ap->a_flags, - ap->a_incred, ap->a_outcred, ap->a_fsizetd); - return (error); + if (invp == outvp) { +generic_copy: + return (vn_generic_copy_file_range(invp, ap->a_inoffp, + outvp, ap->a_outoffp, ap->a_lenp, ap->a_flags, + ap->a_incred, ap->a_outcred, ap->a_fsizetd)); } - mtx_unlock(&nmp->nm_mtx); /* Lock both vnodes, avoiding risk of deadlock. */ do { @@ -3844,6 +3838,23 @@ nfs_copy_file_range(struct vop_copy_file_range_args *ap) if (error != 0) return (error); + /* + * More reasons to avoid nfs copy: not NFSv4.2, or explicitly + * disabled. + */ + nmp = VFSTONFS(invp->v_mount); + mtx_lock(&nmp->nm_mtx); + if (!NFSHASNFSV4(nmp) || nmp->nm_minorvers < NFSV42_MINORVERSION || + (nmp->nm_privflag & NFSMNTP_NOCOPY) != 0) { + mtx_unlock(&nmp->nm_mtx); + VOP_UNLOCK(invp); + VOP_UNLOCK(outvp); + if (mp != NULL) + vn_finished_write(mp); + goto generic_copy; + } + mtx_unlock(&nmp->nm_mtx); + /* * Do the vn_rlimit_fsize() check. Should this be above the VOP layer? */ @@ -3865,6 +3876,7 @@ nfs_copy_file_range(struct vop_copy_file_range_args *ap) error = ncl_flush(outvp, MNT_WAIT, curthread, 1, 0); /* Do the actual NFSv4.2 RPC. */ + ret = ret2 = 0; len = *ap->a_lenp; mtx_lock(&nmp->nm_mtx); if ((nmp->nm_privflag & NFSMNTP_NOCONSECUTIVE) == 0)