From nobody Mon Nov 13 22:28:01 2023 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 4STkb60h5jz50xDS; Mon, 13 Nov 2023 22:28:02 +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 4STkb60F80z3Yym; Mon, 13 Nov 2023 22:28:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699914482; 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=YeMGakgBub7N67Z5sfOWeirvN03QBMc+G2in/bd0UR4=; b=QdbFrVG/NOjnmpQbDvbncw26alS4fvn5VmGehVQFpJw7pUiSCPaGbzGu4HImAUS7GxgUnJ RAUAgxHYrmJXPE2+JhS9RE+fC74T9QDGHx4kuxwnmkiCpwFukZGHQMnq1Ke4kAAhX8taet WVSnRSZXXMk4KxOweCtrFYOGL2/ZNQSQ7PU8k3O+Q+C441DFsN5Qnc4kyqjJyvsSYImI3T A0CjVR5Hx+/DE1xitEc/1asopzSUUURanZ+zIsvxzXzoe6KuL9LuQcrNcWo5GdXaSvI9Uj 52NOBWUc691x/P4QPv+Kz+gyplBQ3zuMCEaxi16cIuvueHEeHnPMKnEN6+xOdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699914482; 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=YeMGakgBub7N67Z5sfOWeirvN03QBMc+G2in/bd0UR4=; b=WcCCL4XaOq4cjPczyLboJmPsWJyqpaMr5VFB7LBKtMCUmGAYBmgeRKe2AbfgwChn6tCScj y7FLs9KqQG0OENqWD/XbJSd+se7dmLC41w8cGCFY8aNP58dJWzOlSlo+VjD5wmYiBh6QSV 4t2anNSyhmwvpnEvT9WYbg4gmxbUfCMWQqBCXSeniBCUQ4P2V1xxbdnXAD6Lz3Y8D5cbQV xtHMcdeZAu/uo4XzIIl9jbXHjcdJEeqFTFkPegKjPa5VdJNpA+ZHzZndOla74hQbZxN09j b/y1Z1sfdF+tivWkZJQt6+5TaZwl51Z+EL89cgVxsMKiSNP0l/9Rs8Y9LHBUlg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699914482; a=rsa-sha256; cv=none; b=mNVRWbut9JrK+E69UEghgiUIfeIkuGhmfHmjxbm60LJC6cTDoWghSLcIhs8jlB/uzk+RrB oNq/yHHzFJaY91NUGQwJgUPVvmXRkChmP3yno8ts7M02eQmd3W8bXEadpqnsiH6olWSD9d n2VKWzmnQxFc3b5xvlo8pEpxAOdrOpW2mHOYa6PKydT5JCYZusiTLDsfG/a/wntWR1Tzwc dfpI8vZ/3/72GjY0ErdacG/SV9IbNeiAmv66MgNLT/NAEZilPbNdNhzL2OFtfScZhcuKGW IUO+qHa6aNTFZjtOarezxtvvIK81s6eZydcDt95znYIbDleuRxQEGGX2pyFvrw== 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 4STkb56PCsz80b; Mon, 13 Nov 2023 22:28:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3ADMS12V063757; Mon, 13 Nov 2023 22:28:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3ADMS19n063754; Mon, 13 Nov 2023 22:28:01 GMT (envelope-from git) Date: Mon, 13 Nov 2023 22:28:01 GMT Message-Id: <202311132228.3ADMS19n063754@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 89188bd6ba8d - main - vn_copy_file_range(): use local variables for invp/outvp vnodes v_mounts 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/main X-Git-Reftype: branch X-Git-Commit: 89188bd6ba8d8332c65498f2b71c90e5ed4b9dae Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=89188bd6ba8d8332c65498f2b71c90e5ed4b9dae commit 89188bd6ba8d8332c65498f2b71c90e5ed4b9dae Author: Konstantin Belousov AuthorDate: 2023-11-12 18:29:14 +0000 Commit: Konstantin Belousov CommitDate: 2023-11-13 22:26:28 +0000 vn_copy_file_range(): use local variables for invp/outvp vnodes v_mounts This avoids possible NULL dereference when checking mnt_vfc names. Reviewed by: jah, rmacklem, Olivier Certner Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42554 --- sys/kern/vfs_vnops.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 4e4161ef1a7f..e2227537dde1 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -3046,6 +3046,7 @@ vn_copy_file_range(struct vnode *invp, off_t *inoffp, struct vnode *outvp, off_t *outoffp, size_t *lenp, unsigned int flags, struct ucred *incred, struct ucred *outcred, struct thread *fsize_td) { + struct mount *inmp, *outmp; int error; size_t len; uint64_t uval; @@ -3075,15 +3076,17 @@ vn_copy_file_range(struct vnode *invp, off_t *inoffp, struct vnode *outvp, if (len == 0) goto out; + inmp = invp->v_mount; + outmp = outvp->v_mount; + /* * If the two vnodes are for the same file system type, call * VOP_COPY_FILE_RANGE(), otherwise call vn_generic_copy_file_range() * which can handle copies across multiple file system types. */ *lenp = len; - if (invp->v_mount == outvp->v_mount || - strcmp(invp->v_mount->mnt_vfc->vfc_name, - outvp->v_mount->mnt_vfc->vfc_name) == 0) + if (inmp == outmp || strcmp(inmp->mnt_vfc->vfc_name, + outmp->mnt_vfc->vfc_name) == 0) error = VOP_COPY_FILE_RANGE(invp, inoffp, outvp, outoffp, lenp, flags, incred, outcred, fsize_td); else