From nobody Fri Dec 26 07:38:32 2025 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 4dcyCX5wxsz6L83F for ; Fri, 26 Dec 2025 07:38: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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dcyCX4C15z47mh for ; Fri, 26 Dec 2025 07:38:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766734712; 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=rhazMNIsfjAxcR9QgTEt/edt8O40s+GDvBj0gXxpDYQ=; b=Shfm1WmLP/LfS7jI9Tc7PlwFgJGBp9bDNLoJSPuo1bt4S6Ek+X3H2gder2D64tk98Iui+5 PZ8R//pOgOM/FSG8fndyDgfiuGKsoon4yXHkk555H8PwJUKzhtOxyPBVSfxAn8QvwL0wBW 6ke7dzTNh8vL3vqdZ6KlM+ucd43eWQiXJVe3eT+wJjxZ0lddNc/HpGBxCkcdHS1I7qJ1Gx XYzQwSzidgAItSABOyujp3OegrL5X757u9w0m0LK2Mgb0K9b/qwFKvmCYTYKq7MANMu3sg f/8RApZVYIuiYqctpjmOfhWrFG3wvPX8PHADmh1tCSE7AudJpXx0p2KT9HfESA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766734712; 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=rhazMNIsfjAxcR9QgTEt/edt8O40s+GDvBj0gXxpDYQ=; b=VIP4zxY8KsVBbBOK/xbb+0GVsJc6ED3+FkOyio9ZmIcXxHgfpRg47mR0axLunwWxznz4oS 3lx2xoqq25hbcWUEz8lNp+rrYX+ykBbxdmi3WKDbzIU+QfQOsmeEf0onsexS/kCRHcJcB7 V2Hz1R+sLH3cOXQntO0Ty/+ZiElsW//iZtURYOFlr5BKatBMcagb4VQMNR/qB9AuY7bvuc cu8at/qsRSvD/pW6+5elgBmQDTVOB8npGy6DxqvHyrSGtyoP5CNviEnF9Blc2NL5SaLaOE Qi+90VTbzEgtnyCxtkPwK41FyRMiTAhvEhbbOYs2ox17vhrr+BHOHFnAYvPmdw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1766734712; a=rsa-sha256; cv=none; b=YwiGSdlixbhF4l/3VVWNiRMmYwAnYnglPXax/FYZSENQkBu8qZAPV0KdPUe89UcrvDjPaY kk+/PqifZlBFc7OvtZhTC/Kg73IowHxDIFVcFrSWHs/nqqkHwhxZyHr5kvnucFRDEUGcRh oqOQXPT46uD3AFt1Dl7nwAfXzkjOD60/wAU5LhJrCq4GdEBYFfZixQbzATEMW3u4xqq2HQ tjzhi421mIyp4XuZeIds0Sdtw6kRhGrZkJ/d4oZL8hY3Ub/M07tjIxQC6rh+0RZ8+St/Xo HBXJQfilNhyCBWXxE9aeIuEe15GES+g/kvKnLoF29dNDQyVC4qEUW21q4wBuBQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dcyCX3WxJz13Vp for ; Fri, 26 Dec 2025 07:38:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 35a42 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 26 Dec 2025 07:38:32 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jason A. Harmening Subject: git: da6f395119a5 - stable/15 - unionfs: detect common deadlock-producing mount misconfigurations 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/15 X-Git-Reftype: branch X-Git-Commit: da6f395119a5eb1ed1dad56874c1c55a5721e220 Auto-Submitted: auto-generated Date: Fri, 26 Dec 2025 07:38:32 +0000 Message-Id: <694e3b78.35a42.3693b1f7@gitrepo.freebsd.org> The branch stable/15 has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=da6f395119a5eb1ed1dad56874c1c55a5721e220 commit da6f395119a5eb1ed1dad56874c1c55a5721e220 Author: Jason A. Harmening AuthorDate: 2025-11-29 07:53:16 +0000 Commit: Jason A. Harmening CommitDate: 2025-12-26 06:38:06 +0000 unionfs: detect common deadlock-producing mount misconfigurations When creating a unionfs mount, it's fairly easy to shoot oneself in the foot by specifying upper and lower file hierarchies that resolve back to the same vnodes. This is fairly easy to do if the sameness is not obvious due to aliasing through nullfs or other unionfs mounts (as in the associated PR), and will produce either deadlock or failed locking assertions on any attempt to use the resulting unionfs mount. Leverage VOP_GETLOWVNODE() to detect the most common cases of foot-shooting at mount time and fail the mount with EDEADLK. This is not meant to be an exhaustive check for all possible deadlock-producing scenarios, but it is an extremely cheap and simple approach that, unlike previous proposed fixes, also works in the presence of nullfs aliases. PR: 172334 Reported by: ngie, Karlo Miličević Reviewed by: kib, olce Tested by: pho Differential Revision: https://reviews.freebsd.org/D53988 (cherry picked from commit 0247b4018de2c341ac59a585362c10044cea86ad) --- sys/fs/unionfs/union_vfsops.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c index 9342317ad08e..fd48a520f911 100644 --- a/sys/fs/unionfs/union_vfsops.c +++ b/sys/fs/unionfs/union_vfsops.c @@ -73,6 +73,8 @@ unionfs_domount(struct mount *mp) { struct vnode *lowerrootvp; struct vnode *upperrootvp; + struct vnode *lvp1; + struct vnode *lvp2; struct unionfs_mount *ump; char *target; char *tmp; @@ -276,11 +278,32 @@ unionfs_domount(struct mount *mp) */ VOP_UNLOCK(ump->um_uppervp); + /* + * Detect common cases in which constructing a unionfs hierarchy + * would produce deadlock (or failed locking assertions) upon + * use of the resulting unionfs vnodes. This typically happens + * when the requested upper and lower filesytems (which themselves + * may be unionfs instances and/or nullfs aliases) end up resolving + * to the same base-layer files. Note that this is not meant to be + * an exhaustive check of all possible deadlock-producing scenarios. + */ + lvp1 = lvp2 = NULL; + VOP_GETLOWVNODE(ump->um_lowervp, &lvp1, FREAD); + VOP_GETLOWVNODE(ump->um_uppervp, &lvp2, FREAD); + if (lvp1 != NULL && lvp1 == lvp2) + error = EDEADLK; + if (lvp1 != NULL) + vrele(lvp1); + if (lvp2 != NULL) + vrele(lvp2); + /* * Get the unionfs root vnode. */ - error = unionfs_nodeget(mp, ump->um_uppervp, ump->um_lowervp, - NULLVP, &(ump->um_rootvp), NULL); + if (error == 0) { + error = unionfs_nodeget(mp, ump->um_uppervp, ump->um_lowervp, + NULL, &(ump->um_rootvp), NULL); + } if (error != 0) { vrele(upperrootvp); free(ump, M_UNIONFSMNT);