Windows: avoid deadlock with Trend Micro
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 30 Mar 2012 03:49:43 +0000 (23:49 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 30 Mar 2012 13:08:38 +0000 (06:08 -0700)
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 <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp

index 86751d0..64b8ea4 100644 (file)
@@ -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)
             {
@@ -2015,6 +2023,20 @@ AFSSetDispositionInfo( IN PIRP Irp,
                 }
 
                 //
+                // 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
         {