git: 0cd8f3e958a5 - main - unionfs: fix assertion order in unionfs_lock()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 03 Feb 2022 02:58:20 UTC
The branch main has been updated by jah:
URL: https://cgit.FreeBSD.org/src/commit/?id=0cd8f3e958a514588af85f5aa6ef3d0526b4d4f0
commit 0cd8f3e958a514588af85f5aa6ef3d0526b4d4f0
Author: Jason A. Harmening <jah@FreeBSD.org>
AuthorDate: 2022-01-30 20:43:19 +0000
Commit: Jason A. Harmening <jah@FreeBSD.org>
CommitDate: 2022-02-03 03:08:17 +0000
unionfs: fix assertion order in unionfs_lock()
VOP_LOCK() may be handed a vnode that is concurrently reclaimed.
unionfs_lock() accounts for this by checking for empty vnode private
data under the interlock. But it incorrectly asserts that the vnode
is using the unionfs dispatch table before making this check.
Reverse the order, and also update KASSERT_UNIONFS_VNODE() to provide
more useful information.
Reported by: pho
Reviewed by: kib, markj, pho
Differential Revision: https://reviews.freebsd.org/D34109
---
sys/fs/unionfs/union_vnops.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c
index c9d8aac12362..43378f709df7 100644
--- a/sys/fs/unionfs/union_vnops.c
+++ b/sys/fs/unionfs/union_vnops.c
@@ -76,8 +76,8 @@
#endif
#define KASSERT_UNIONFS_VNODE(vp) \
- KASSERT(((vp)->v_op == &unionfs_vnodeops), \
- ("unionfs: it is not unionfs-vnode"))
+ VNASSERT(((vp)->v_op == &unionfs_vnodeops), vp, \
+ ("%s: non-unionfs vnode", __func__))
static int
unionfs_lookup(struct vop_cachedlookup_args *ap)
@@ -1918,8 +1918,6 @@ unionfs_lock(struct vop_lock1_args *ap)
int interlock;
int uhold;
- KASSERT_UNIONFS_VNODE(ap->a_vp);
-
/*
* TODO: rework the unionfs locking scheme.
* It's not guaranteed to be safe to blindly lock two vnodes on
@@ -1945,6 +1943,9 @@ unionfs_lock(struct vop_lock1_args *ap)
unp = VTOUNIONFS(vp);
if (unp == NULL)
goto unionfs_lock_null_vnode;
+
+ KASSERT_UNIONFS_VNODE(ap->a_vp);
+
lvp = unp->un_lowervp;
uvp = unp->un_uppervp;