From nobody Sat Nov 4 17:15:50 2023 X-Original-To: dev-commits-src-main@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 4SN4524GXNz4yvkD; Sat, 4 Nov 2023 17:15:50 +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 4SN4523Ybwz3Q6q; Sat, 4 Nov 2023 17:15:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699118150; 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=wIJjiLrIhxTgo/C+YgCGkwCRKM6KLrTZAIwVpq4eVZM=; b=ow8kUvsFjzuxqZogzIjTAdmNpby3HATbthKU5/lrtvkm/MlhQfOLjHgRMS1BCJGGbvbsBY AkYVCHquFne3i+BqfaK3Y/dJMfp2RD3h6Psi3IAcFgkKRUWoz71hBAZJ1/GHneRURlTNzc FEcoesG9yMzIXDZBLi9WnNV0p82vh5MQLZoIGm+C8b9zia9gJ1SJacDLkHhSvMvQlEQchH XhJZG6vYzzqJcy9kfcSCgga1liXPJp2YNUX/bVOcRxVadAboiYSiWiVQnsu4ufOSmrqosv Go043zd4CRofZxJ8NJ2H28ANC44VnK/0ASkaHX2tT689dbVR7Kq7JRepPF84yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699118150; 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=wIJjiLrIhxTgo/C+YgCGkwCRKM6KLrTZAIwVpq4eVZM=; b=nuA4g0RZsvhlR36esVQm6OgWt6DmqsYcO353m2M/ookZxykW0iAs762zSDlB6byLyFQHZB KCM6CtUU4iq9V+R2inck/GG5wI23eG5/vzgrkPgWVFLsd5A/5GkrThDuylaPR0kk+M+fVO xmMmQrCkuB9GowVvIKo5adrf4EJg+7OMOUefI42wzfXpCve5wxCVX2/l6Mc78ND2sxe6V2 es/w0kjRVN2TUaCWZ9wOE5jZYBecsmOFKrgjcXmSUK63MziqnIq2xKfpHdsJ4MhyNHej4H 3zG2GJ4RSOCLdDSGlbNu2YEzh2wMM50ps3KGtPjuXivmJ20wUcmP2gFjQANklw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699118150; a=rsa-sha256; cv=none; b=tnzoMSJADpNoUqpMGtRPTCtbEp7JjcSqgw0IKQq0rPFGZf/3/qfnfFxL1Kn16hCJHZ61kT gt/DcggvqQBC8JYyx+icGqVK1ltHTT5WwP2ZO234UuUQhy4gWhJVo1VfDu7pg+bL6sMjlZ PTvIGK88nwMJHMTLpH7TOGEun/sklxQgy4GasLMFqjnAdJTF4pEsOcvfXIRo6CmQK7TvhS x5FZE8ydygcESjUHvxv7WdKTZhm575G91u7Ao4kQ9IjLeSs+8a7nzqZX4Tcnc8NEl+PCnK QeB0pfQmbboVMMAktIFZSl4yzVfr2Fhncm93QflJxqO1cotCe39qyT/l1tzW6g== 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 4SN4522dVxz15mn; Sat, 4 Nov 2023 17:15:50 +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 3A4HFoxv004111; Sat, 4 Nov 2023 17:15:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A4HFoZW004108; Sat, 4 Nov 2023 17:15:50 GMT (envelope-from git) Date: Sat, 4 Nov 2023 17:15:50 GMT Message-Id: <202311041715.3A4HFoZW004108@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: 586fed0b0356 - main - vfs_lookup_cross_mount(): restore previous do...while loop List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 586fed0b03561558644eccc37f824c7110500182 Auto-Submitted: auto-generated The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=586fed0b03561558644eccc37f824c7110500182 commit 586fed0b03561558644eccc37f824c7110500182 Author: Jason A. Harmening AuthorDate: 2023-11-04 16:56:45 +0000 Commit: Jason A. Harmening CommitDate: 2023-11-04 17:15:20 +0000 vfs_lookup_cross_mount(): restore previous do...while loop When the cross-mount walking logic in vfs_lookup() was factored into a separate function, the main cross-mount traversal loop was changed from a do...while loop conditional on the current vnode having VIRF_MOUNTPOINT set to an unconditional for(;;) loop. For the unionfs 'crosslock' case in which the vnode may be re-locked, this meant that continuing the loop upon finding inconsistent v_mountedhere state would no longer branch to a check that the vnode is in fact still a mountpoint. This would in turn lead to over- iteration and, for INVARIANTS builds, a failed assert on the next iteration. Fix this by restoring the previous loop behavior. Reported by: pho Tested by: pho Fixes: 80bd5ef0702562c546fa1717e8fe221058974eac MFC after: 1 week --- sys/kern/vfs_lookup.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index d75351c34314..922adda33b94 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -882,7 +882,7 @@ vfs_lookup_cross_mount(struct nameidata *ndp) * The vnode has been mounted on, find the root of the mounted * filesystem. */ - for (;;) { + do { mp = dp->v_mountedhere; ASSERT_VOP_LOCKED(dp, __func__); VNPASS((vn_irflag_read(dp) & VIRF_MOUNTPOINT) != 0 && mp != NULL, dp); @@ -915,6 +915,12 @@ vfs_lookup_cross_mount(struct nameidata *ndp) break; } if (dp->v_mountedhere != mp) { + /* + * Note that we rely on the + * VIRF_MOUNTPOINT loop condition to + * ensure we stop iterating if dp is + * no longer a mountpoint at all. + */ continue; } } else @@ -939,9 +945,7 @@ vfs_lookup_cross_mount(struct nameidata *ndp) if (error != 0) break; ndp->ni_vp = dp = tdp; - if ((vn_irflag_read(dp) & VIRF_MOUNTPOINT) == 0) - break; - } + } while ((vn_irflag_read(dp) & VIRF_MOUNTPOINT) != 0); return (error); }