From 81c4868c0a715c2fe5fc2df73541b8d1dbec80a2 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 24 Aug 2012 17:09:58 -0700 Subject: [PATCH] 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). --- sys/kern/vfs_cache.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index bbd46e8..d4899d3 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2596,6 +2596,20 @@ restart: } /* + * 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. */ -- 1.7.7.2