Module Name: src Committed By: hannken Date: Thu Apr 5 07:26:37 UTC 2012
Modified Files: src/sys/kern: vfs_vnops.c Log Message: Fix vn_lock() to return an invalid (dead, clean) vnode only if the caller requested it by setting LK_RETRY. Should fix PR #46221: Kernel panic in NFS server code To generate a diff of this commit: cvs rdiff -u -r1.183 -r1.184 src/sys/kern/vfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/vfs_vnops.c diff -u src/sys/kern/vfs_vnops.c:1.183 src/sys/kern/vfs_vnops.c:1.184 --- src/sys/kern/vfs_vnops.c:1.183 Fri Oct 14 09:23:31 2011 +++ src/sys/kern/vfs_vnops.c Thu Apr 5 07:26:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnops.c,v 1.183 2011/10/14 09:23:31 hannken Exp $ */ +/* $NetBSD: vfs_vnops.c,v 1.184 2012/04/05 07:26:36 hannken Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.183 2011/10/14 09:23:31 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.184 2012/04/05 07:26:36 hannken Exp $"); #include "veriexec.h" @@ -805,6 +805,15 @@ vn_lock(struct vnode *vp, int flags) } else { mutex_exit(vp->v_interlock); error = VOP_LOCK(vp, (flags & ~LK_RETRY)); + if (error == 0 && (flags & LK_RETRY) == 0) { + mutex_enter(vp->v_interlock); + if ((vp->v_iflag & VI_CLEAN)) { + mutex_exit(vp->v_interlock); + VOP_UNLOCK(vp); + return ENOENT; + } + mutex_exit(vp->v_interlock); + } if (error == 0 || error == EDEADLK || error == EBUSY) return (error); }