From nobody Tue Jun 14 07:33:22 2022 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 1BD84832BDC; Tue, 14 Jun 2022 07:33: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 4LMgCR0GrHz52Sp; Tue, 14 Jun 2022 07:33:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655192003; 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=oy/UqfsEAtJGeq3buqE2FwOLyVVDlIE0U6xsKdIlME4=; b=qaSAuCMMAUV1fRiCyiV/zRQ48EGaSymEdbvPl9ZkEAtDm1GUNzpK0p553gGv0O3oOQCWU5 j4xeJ4bmTarpt1J92J29J+VhaXN5Xq/2fdyH5E99+WJ913/V7QcHhq41il7EouRCfGMzjw jqwoBnEzbtMjBDhYtxCZi1WoHaVaQzHhNUpDQFB9r9U97qkqzA+TqmZErQS9rd9sRQ8QvQ 4n8Wbn1Yym6s7V11AkvSOWHORV/G+OE3hKKAeDzI3+StxVM0yIZjq0ut8Ba/Q3mMLAYHwg LVvJH8SqaY3z6FIltmpEAuoeYjBoolKRZAkNHqPRq5fAIKMeLYj0LK9BpOgpNA== 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 DDF1725F5B; Tue, 14 Jun 2022 07:33: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 25E7XMpT096718; Tue, 14 Jun 2022 07:33:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25E7XMft096717; Tue, 14 Jun 2022 07:33:22 GMT (envelope-from git) Date: Tue, 14 Jun 2022 07:33:22 GMT Message-Id: <202206140733.25E7XMft096717@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: 7fd37611b92b - main - null_vptocnp(): busy nullfs mp instead of refing it 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7fd37611b92b5f365f33435bb725b335c2f10ba8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655192003; 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=oy/UqfsEAtJGeq3buqE2FwOLyVVDlIE0U6xsKdIlME4=; b=VZfVA8tP9RsM6zZftu/xQnWakZ4O5pkBbEm7IDv9RmlH64ieMizKt27sA1eAwtWWgzpQZy 2uaMh9tPrakDGe8vcF+6TYtOhUKazsk4v0oFsZz7k4BKGS2AyccJVrPFG378yHbsyqlklD OnjC1RujpXSfq6eQqW39dysAxQF3zrkx6WC/cnVSVTftCZJ+NUy1peuXK5gFjwaw0dX7b1 fgSikJhKv+kvwoYLGdZNs3vBu0rBEBiSHe4UxAIDyGxYVRpESj7Upy//1A9tOipN1AX0Ih 91ysH/YklmmyFS16hBCCNJtB+3yLszNX0gqK2CMie20Rq7Yr0hlt2YFzPjwpsg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655192003; a=rsa-sha256; cv=none; b=FSjVKNguMPTw2hOkI1PXxz9fYOeNoJnImxexBSbylhI0Hhd/3hFSnV2jzFgq43fpvp2JeX ZDsmQBZUvcNfgBrX1Cfoth5/Z0duF+su7wn/Wnh4Ugi7uclnNnW02dq5XeUHSDXsFmrDY1 ar8HBRPydTte+nSmYdH2q3x26X+rA9vzvvmfIClGp1m4TR5+WozTJGgsySmMX9W/J0a+en sAubGIaN3HMShZkY1zrwJAemYWP6MB1StWyJte0Rb71BvwuIempj5Ock+em0UnrswrcGvC zrnR63RAwz1MCEKFH7VxS1Bz6vDn4jDVXYg4rxme3armsotmafLhKXUTIWNpTw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7fd37611b92b5f365f33435bb725b335c2f10ba8 commit 7fd37611b92b5f365f33435bb725b335c2f10ba8 Author: Konstantin Belousov AuthorDate: 2022-06-10 11:35:45 +0000 Commit: Konstantin Belousov CommitDate: 2022-06-14 07:32:45 +0000 null_vptocnp(): busy nullfs mp instead of refing it null_nodeget() needs a valid mount point data, otherwise we might race and dereference NULL. Using MBF_NOWAIT makes non-forced unmount non-transparent for vn_fullpath() over nullfs, but we make no guarantee that fullpath calculation succeeds anyway. Reported and tested by: pho Reviewed by: jah Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D35477 --- sys/fs/nullfs/null_vnops.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index e3a320a22bfa..bb18bc8ee55f 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -989,9 +989,11 @@ null_vptocnp(struct vop_vptocnp_args *ap) locked = VOP_ISLOCKED(vp); lvp = NULLVPTOLOWERVP(vp); - vhold(lvp); mp = vp->v_mount; - vfs_ref(mp); + error = vfs_busy(mp, MBF_NOWAIT); + if (error != 0) + return (error); + vhold(lvp); VOP_UNLOCK(vp); /* vp is held by vn_vptocnp_locked that called us */ ldvp = lvp; vref(lvp); @@ -999,7 +1001,7 @@ null_vptocnp(struct vop_vptocnp_args *ap) vdrop(lvp); if (error != 0) { vn_lock(vp, locked | LK_RETRY); - vfs_rel(mp); + vfs_unbusy(mp); return (ENOENT); } @@ -1007,7 +1009,7 @@ null_vptocnp(struct vop_vptocnp_args *ap) if (error != 0) { vrele(ldvp); vn_lock(vp, locked | LK_RETRY); - vfs_rel(mp); + vfs_unbusy(mp); return (ENOENT); } error = null_nodeget(mp, ldvp, dvp); @@ -1018,7 +1020,7 @@ null_vptocnp(struct vop_vptocnp_args *ap) VOP_UNLOCK(*dvp); /* keep reference on *dvp */ } vn_lock(vp, locked | LK_RETRY); - vfs_rel(mp); + vfs_unbusy(mp); return (error); }