From b30c9dcfacb3785360c422c19ef2cc0eea151291 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 6 Dec 2012 14:59:22 -0500 Subject: [PATCH] Windows: SetDispositionInfo !MmFlush SectionObjectResource In AFSSetDispositionInfo() if MmFlushImageSection() fails, be sure to release the SectionObjectResource. Change-Id: Ic0a31627369d0fa055f78e5949314398f58569e0 Reviewed-on: http://gerrit.openafs.org/8714 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp | 69 ++++++++++++--------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp b/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp index 0d9d8965e..c3547a7f2 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp @@ -2107,6 +2107,7 @@ AFSSetDispositionInfo( IN PIRP Irp, } else if( pFcb->Header.NodeTypeCode == AFS_FILE_FCB) { + BOOLEAN bMmFlushed; AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING, AFS_TRACE_LEVEL_VERBOSE, @@ -2121,46 +2122,41 @@ AFSSetDispositionInfo( IN PIRP Irp, // Attempt to flush any outstanding data // - if( !MmFlushImageSection( &pFcb->NPFcb->SectionObjectPointers, - MmFlushForDelete)) + bMmFlushed = MmFlushImageSection( &pFcb->NPFcb->SectionObjectPointers, + MmFlushForDelete); + + if ( bMmFlushed) { + // + // 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_ERROR, - "AFSSetDispositionInfo Failed to flush image section for delete Entry %wZ\n", + AFS_TRACE_LEVEL_VERBOSE, + "AFSSetDispositionInfo Setting PENDING_DELETE on DirEntry %p Name %wZ\n", + DirectoryCB, &DirectoryCB->NameInformation.FileName); - try_return( ntStatus = STATUS_CANNOT_DELETE); - } + SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_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 - // - - if( pFcb->NPFcb->SectionObjectPointers.DataSectionObject != NULL) - { + // + // Purge the cache as well + // - if ( !CcPurgeCacheSection( &pFcb->NPFcb->SectionObjectPointers, - NULL, - 0, - TRUE)) + if( pFcb->NPFcb->SectionObjectPointers.DataSectionObject != NULL) { - SetFlag( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE); + if ( !CcPurgeCacheSection( &pFcb->NPFcb->SectionObjectPointers, + NULL, + 0, + TRUE)) + { + + SetFlag( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE); + } } } @@ -2171,6 +2167,17 @@ AFSSetDispositionInfo( IN PIRP Irp, PsGetCurrentThread()); AFSReleaseResource( &pFcb->NPFcb->SectionObjectResource); + + if ( !bMmFlushed) + { + + AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING, + AFS_TRACE_LEVEL_ERROR, + "AFSSetDispositionInfo Failed to flush image section for delete Entry %wZ\n", + &DirectoryCB->NameInformation.FileName); + + try_return( ntStatus = STATUS_CANNOT_DELETE); + } } } else -- 2.39.5