From: Matthew Dillon Date: Sat, 25 Aug 2012 00:09:58 +0000 (-0700) Subject: kernel - Do not allow destroyed namecache entries to be re-resolved X-Git-Tag: v3.2.0~262 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/81c4868c0a715c2fe5fc2df73541b8d1dbec80a2 kernel - Do not allow destroyed namecache entries to be re-resolved * Do not allow a destroyed namecache entry to be re-resolved, as it might resolve as a completely different file, or even resolve as a file when it was originally a directory and so forth. * Fixes inconsistencies in the current-dir fields in proc->p_fd. * Note that most VFS's can't re-resolve a disconnected directory anyway but HAMMER1 actually can, so this was causing a problem in tests with HAMMER1 (the same tests that originally crashed tmpfs were also crashing HAMMER1, but for a different reason). --- diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index bbd46e8321..d4899d364d 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2595,6 +2595,20 @@ restart: return (ncp->nc_error); } + /* + * If the ncp was destroyed it will never resolve again. This + * can basically only happen when someone is chdir'd into an + * empty directory which is then rmdir'd. We want to catch this + * here and not dive the VFS because the VFS might actually + * have a way to re-resolve the disconnected ncp, which will + * result in inconsistencies in the cdir/nch for proc->p_fd. + */ + if (ncp->nc_flag & NCF_DESTROYED) { + kprintf("Warning: cache_resolve: ncp '%s' was unlinked\n", + ncp->nc_name); + return(EINVAL); + } + /* * Mount points need special handling because the parent does not * belong to the same filesystem as the ncp.