From 134943a7a55d73f567d3f336e06783c405347fa7 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 29 Mar 2012 23:49:43 -0400 Subject: [PATCH] Windows: avoid deadlock with Trend Micro Trend Micro's anti-virus driver attempts to open the file in response to CcPurgeCacheSection(). While processing AFSSetDispositionInfo() the Fcb->NPFcb->Resource is held which is also required if a status verification is required during the CreateFile operation. That results in a deadlock. Avoid the deadlock by setting the PENDING_DELETE flag prior to calling CcPurgeCacheSection(). Change-Id: I40d93d70e120525343afb917d473ad79a1f36e29 Reviewed-on: http://gerrit.openafs.org/6988 Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp | 30 +++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp b/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp index 86751d0fa6..64b8ea4beb 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp @@ -1994,6 +1994,14 @@ AFSSetDispositionInfo( IN PIRP Irp, try_return( ntStatus = STATUS_DIRECTORY_NOT_EMPTY); } + + AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSSetDispositionInfo Setting PENDING_DELETE on DirEntry %p Name %wZ\n", + DirectoryCB, + &DirectoryCB->NameInformation.FileName); + + SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE); } else if( pFcb->Header.NodeTypeCode == AFS_FILE_FCB) { @@ -2014,6 +2022,20 @@ AFSSetDispositionInfo( IN PIRP Irp, try_return( ntStatus = STATUS_CANNOT_DELETE); } + // + // Set PENDING_DELETE before CcPurgeCacheSection to avoid a + // deadlock with Trend Micro's Enterprise anti-virus product + // which attempts to open the file which is being deleted. + // + + AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSSetDispositionInfo Setting PENDING_DELETE on DirEntry %p Name %wZ\n", + DirectoryCB, + &DirectoryCB->NameInformation.FileName); + + SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE); + // // Purge the cache as well // @@ -2027,14 +2049,6 @@ AFSSetDispositionInfo( IN PIRP Irp, TRUE); } } - - AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSSetDispositionInfo Setting PENDING_DELETE on DirEntry %p Name %wZ\n", - DirectoryCB, - &DirectoryCB->NameInformation.FileName); - - SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE); } else {