unionfs: fixes to unionfs_nodeget() error handling

If either the lower or upper vnode is found to be doomed after
locking it, the newly-created unionfs node won't be associated
with it and its lock will be dropped.  In that case, clear the
uppervp and lowervp locals as necessary to avoid further use
of the vnode in unionfs_nodeget().  If the upper vnode is doomed
but the lower vnode remains valid, additionally reset the unionfs
node's v_vnlock field to point to the lower vnode lock.

Reviewed by:	kib, markj
Tested by:	pho
Differential Revision:	https://reviews.freebsd.org/D39767
This commit is contained in:
Jason A. Harmening 2023-03-25 20:30:25 -05:00
parent 95950880ad
commit 0809172985

View File

@ -397,13 +397,15 @@ unionfs_nodeget(struct mount *mp, struct vnode *uppervp,
}
if (lowervp != NULL && VN_IS_DOOMED(lowervp)) {
vput(lowervp);
unp->un_lowervp = NULL;
unp->un_lowervp = lowervp = NULL;
}
if (uppervp != NULL && VN_IS_DOOMED(uppervp)) {
vput(uppervp);
unp->un_uppervp = NULL;
unp->un_uppervp = uppervp = NULL;
if (lowervp != NULLVP)
vp->v_vnlock = lowervp->v_vnlock;
}
if (unp->un_lowervp == NULL && unp->un_uppervp == NULL) {
if (lowervp == NULL && uppervp == NULL) {
unionfs_nodeget_cleanup(vp, unp);
return (ENOENT);
}