From nobody Sat Apr 27 17:46:31 2024 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 4VRcTh357Yz5JYQH; Sat, 27 Apr 2024 17:46:32 +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 4VRcTg6fHxz4cg0; Sat, 27 Apr 2024 17:46:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714239991; 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=SJ8quz4v64ffauJq07kQYdegH9cebyDCQoonxRBugEQ=; b=vSk/4GSSGtDzGlJM/MqBxvO0yBRwwVm9TLSDXBNdMJoSXMFR1avHD1ksZG/RUJs4Zp/mWC /snkiyaScQbwT6zgnPG4C0djjLyxEwKV4U8gDbc1rLuBMOJTNFy5WJ48A2e7d6bNqqX1UX H0MSakvO2pGM/Un2CaHV3e4vYZTu8TnMNwIwMdlJJBeg7IG9X4IqemCWv/lJK1bRd3UES1 dM+nlOciqR0qnwYvH1EVE6Kju2A3yWZDeN1Z++HBnqYRc+ZcEbbSPGoD2+yyIPaSc2zOS7 tM2fILkx1jBiV9Xb5Opdfb840OM3OrgRlGTZMe5z90D84uywvEktR4jg0ju1Bg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714239991; a=rsa-sha256; cv=none; b=swDaApWuLkODQ1HTL/2vrKLDlK6lxuTJSfv+vR76zWLlAzrVYZjswYsvr65JfW4wKnWUxq l/VXpU63goIC7xkY5aAoThkjnFE+AmUUpi6WalhD7WpZvU9mr24HLJHD8aBGNgx3qxq/OG vhlEOYgJVyKGLjI+Zyu5WIzML6sqQbRBWWH805OmLnWuTdM8bvbTlXE68/BK3EShrGcixB YhFCNsO7PidXAmcRZYFHGc9JCVgSIkirZPNDhSt5CAqHAcTSGch80R94K43cI26Y0EW7UN 1PMkok6KmWr9HRaj5u5nh7nhbupuQHW+qCK+RrCXSg1sNhYsEtRfJVcsHIZTaw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714239991; 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=SJ8quz4v64ffauJq07kQYdegH9cebyDCQoonxRBugEQ=; b=fTJNy5uV+3Qs+oRSZan8w8Zi3ySeqH6I4LIWLD7abUFyLPCYBq+n9rLfrT6UBT4Q49MGmR dm51cQARM2SQlq8u6/mtCrqQt0bUjRTPJyJS1VZJGxNzDbRaLYKcH02GlI53EI6a1XH10/ ZNrGLSylm2O3cbrvTTFZ5ve+Odk3gDlJSY07kC2mfp6907pUbgveNZDrfldbx3OGKuBv6E K9+HyFosWG/LNut/cQpHQFhLl/8efe91lzEqS5b4JD2CPOSG0hcLmEdJZVrOWI7tcgxh0y nCqbhO+cT0w92JA1nGIbNgi3e8M28BXUCpz0LBxEPGqgZhwqB4IpYA4a/H/KuA== 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 4VRcTg6FSZzrPB; Sat, 27 Apr 2024 17:46:31 +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 43RHkVmL020324; Sat, 27 Apr 2024 17:46:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43RHkVLN020321; Sat, 27 Apr 2024 17:46:31 GMT (envelope-from git) Date: Sat, 27 Apr 2024 17:46:31 GMT Message-Id: <202404271746.43RHkVLN020321@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Jason A. Harmening" Subject: git: c8d6c9351a92 - stable/14 - unionfs_lookup(): fix wild accesses to vnode private data 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jah X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: c8d6c9351a9255becf3a772be441d4648b998306 Auto-Submitted: auto-generated The branch stable/14 has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=c8d6c9351a9255becf3a772be441d4648b998306 commit c8d6c9351a9255becf3a772be441d4648b998306 Author: Jason A. Harmening AuthorDate: 2024-02-18 00:19:32 +0000 Commit: Jason A. Harmening CommitDate: 2024-04-27 17:42:36 +0000 unionfs_lookup(): fix wild accesses to vnode private data There are a few spots in which unionfs_lookup() accesses unionfs vnode private data without holding the corresponding vnode lock or interlock. Reviewed by: kib, olce Differential Revision: https://reviews.freebsd.org/D44601 (cherry picked from commit b18029bc59d2ed6b0eeeb233189cf713b34b467c) --- sys/fs/unionfs/union_vnops.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index 5a2d4751ed4f..eff437fbcad3 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -81,7 +81,7 @@ static int unionfs_lookup(struct vop_cachedlookup_args *ap) { - struct unionfs_node *dunp; + struct unionfs_node *dunp, *unp; struct vnode *dvp, *udvp, *ldvp, *vp, *uvp, *lvp, *dtmpvp; struct vattr va; struct componentname *cnp; @@ -141,6 +141,9 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) if (dtmpvp == udvp && ldvp != NULLVP) { VOP_UNLOCK(udvp); vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); + dunp = VTOUNIONFS(dvp); + if (error == 0 && dunp == NULL) + error = ENOENT; } if (error == 0) { @@ -154,14 +157,15 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) VOP_UNLOCK(vp); vrele(vp); + dtmpvp = dunp->un_dvp; + vref(dtmpvp); VOP_UNLOCK(dvp); - *(ap->a_vpp) = dunp->un_dvp; - vref(dunp->un_dvp); + *(ap->a_vpp) = dtmpvp; if (nameiop == DELETE || nameiop == RENAME) - vn_lock(dunp->un_dvp, LK_EXCLUSIVE | LK_RETRY); + vn_lock(dtmpvp, LK_EXCLUSIVE | LK_RETRY); else if (cnp->cn_lkflags & LK_TYPE_MASK) - vn_lock(dunp->un_dvp, cnp->cn_lkflags | + vn_lock(dtmpvp, cnp->cn_lkflags | LK_RETRY); vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); @@ -274,8 +278,12 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); lockflag = 1; } - error = unionfs_mkshadowdir(MOUNTTOUNIONFSMOUNT(dvp->v_mount), - udvp, VTOUNIONFS(vp), cnp, td); + unp = VTOUNIONFS(vp); + if (unp == NULL) + error = ENOENT; + else + error = unionfs_mkshadowdir(MOUNTTOUNIONFSMOUNT(dvp->v_mount), + udvp, unp, cnp, td); if (lockflag != 0) VOP_UNLOCK(vp); if (error != 0) {