diff options
author | Robert Watson <rwatson@FreeBSD.org> | 2000-01-29 15:22:58 +0000 |
---|---|---|
committer | Robert Watson <rwatson@FreeBSD.org> | 2000-01-29 15:22:58 +0000 |
commit | 9a2b8fca80d97f62401565c1c0a0bbdea354f5be (patch) | |
tree | 49fb9237da885329d9c6dacb6a923ca463907086 /sys/kern/vfs_export.c | |
parent | 8f8e58794866a5a4439a329fdfbf1203064f4952 (diff) | |
download | src-9a2b8fca80d97f62401565c1c0a0bbdea354f5be.tar.gz src-9a2b8fca80d97f62401565c1c0a0bbdea354f5be.zip |
This patch fixes a locking bug that can result in deadlock if
the codepath is followed.
From the PR:
vclean calls vrele leading to deadlock (if usecount > 0)
vclean() calls vrele() if v_usecount of the node was higher than one.
But before calling it, it sets the VXLOCK flag, which will make
vn_lock called from vrele dead-lock.
PR: kern/15117
Submitted by: Assar Westerlund <assar@stacken.kth.se>
Reviewed by: rwatson
Obtained from: NetBSD
Notes
Notes:
svn path=/head/; revision=56837
Diffstat (limited to 'sys/kern/vfs_export.c')
-rw-r--r-- | sys/kern/vfs_export.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c index 97d62510b83e..e0ef113e50c1 100644 --- a/sys/kern/vfs_export.c +++ b/sys/kern/vfs_export.c @@ -1701,8 +1701,23 @@ vclean(vp, flags, p) if (VOP_RECLAIM(vp, p)) panic("vclean: cannot reclaim"); - if (active) - vrele(vp); + if (active) { + /* + * Inline copy of vrele() since VOP_INACTIVE + * has already been called. + */ + simple_lock(&vp->v_interlock); + if (--vp->v_usecount <= 0) { +#ifdef DIAGNOSTIC + if (vp->v_usecount < 0 || vp->v_writecount != 0) { + vprint("vclean: bad ref count", vp); + panic("vclean: ref cnt"); + } +#endif + vfree(vp); + } + simple_unlock(&vp->v_interlock); + } cache_purge(vp); if (vp->v_vnlock) { |