From nobody Tue Apr 09 22:38:02 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 4VDgpL2pC6z5G9RF; Tue, 9 Apr 2024 22:38: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 4VDgpL29rGz41KC; Tue, 9 Apr 2024 22:38:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712702282; 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=hytN9egvCfa0KvXl/BtQ/YSxKJs36adHXYac+0C6oYM=; b=hu4FhbG7yPEBRGLCvKrg68IoAmQbcSZ7RrIQGL+HU4VwXSllQs2PkmRdSbbcWBcVzRFxV1 /r9TWZmobkcXFRpKJGjR39DeQJtH9ajDG7i1pmtybGdCcVB560nvRDdXaOakYmQJ81OwPI 7aXBYjF5a7gK+/t0ymk7AFydGeP/SQq2Ex7EVu3gnNqYTvl3XDaxGFQtTaFIOqTFEsCq5R 3XoTJDqWyCeqJyCk4LL1M1N0jwGsru3ZeQiQdgHE5xWPhvgEEYkkOYOaiHkunaLxWotTGa VLpwZCdCohDPATSNWVh3aGRaEbfIP5zgBBpIpKW1+bXkdkGPTU31x3TfgEyIsg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712702282; a=rsa-sha256; cv=none; b=u0p83cqTiZ0ddhPQaqPA/7w4tKE71YjbCZ+6hCvJFqUMsf2MF9S20ZwPyRfUl04+uBDQD0 Me5taxOphUI2RGpI49ECQy6nm7ypm22N5bIXGyKGX4AsiEigyacqz3rgTpNB+6tWpc4Evv CM1JEIdtNUTYJMnic+M6DrWp0l9Jh9G2ucTjtEiuMWDVxzW7aOBWZS9DdcOtBuA3YPJ7sB 5kXSBaZAoDrM4Gc7j5WP/dF1X8bK87qIjui4A2vZ9EtnwXNas5ulLAAqDDVabKWjhPEZNv VSyfDbCq3aFdFX9Pz0V8gGuzpGHsPOYlNKcka8KbrmDH3HQZwuPU2odPJojGZg== 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=1712702282; 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=hytN9egvCfa0KvXl/BtQ/YSxKJs36adHXYac+0C6oYM=; b=AOnrMx3oq/66Eru3JoC1rt7ZMH3R9wG5koDimeWIoH/xuE26y986xZfHl9wZ2TIzNJCUtL FyPLQF+okPvMyMnVRFurRLfQ+CJM2a8Rzo7Wnu8T8dQ5ojqlh0k8NTXOfsBIiRhJBvuPDU a+FUFICFJa8g6SJCIpCeuxVBsoQJdBcYfjs/3hz6vrrgj9uq3i9cohF7WRRG23Dv7Vma+F njTAQRU3vGCtDZHVJ/nCHW4dP7JWIMg2DMSmL+C8GwT63M8Q5piOIWDR7dN2z4DWgTKytP ii7ihkuIxx0Q6JSNPLGdTuR1mrn7hxlqWoPai0Vc4Dw+uyQHXUEmO/N1sv6c3A== 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 4VDgpL1nlMz1CGm; Tue, 9 Apr 2024 22:38:02 +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 439Mc2n8099834; Tue, 9 Apr 2024 22:38:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 439Mc2B9099831; Tue, 9 Apr 2024 22:38:02 GMT (envelope-from git) Date: Tue, 9 Apr 2024 22:38:02 GMT Message-Id: <202404092238.439Mc2B9099831@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Jason A. Harmening" Subject: git: b18029bc59d2 - main - 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: Sender: dev-commits-src-all+owner@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: jah X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b18029bc59d2ed6b0eeeb233189cf713b34b467c Auto-Submitted: auto-generated The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=b18029bc59d2ed6b0eeeb233189cf713b34b467c commit b18029bc59d2ed6b0eeeb233189cf713b34b467c Author: Jason A. Harmening AuthorDate: 2024-02-18 00:19:32 +0000 Commit: Jason A. Harmening CommitDate: 2024-04-09 22:36:59 +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 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D44601 --- 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 3e8853baeb4d..187d0513da25 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -79,7 +79,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; @@ -139,6 +139,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) { @@ -152,14 +155,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); @@ -272,8 +276,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) {