https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8a8cb4d8907c698b70b0c…
commit 8a8cb4d8907c698b70b0cb5688bea805f68537b8
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Wed May 23 08:37:50 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Wed May 23 08:41:46 2018 +0200
[NTOSKRNL] Only consider SharedCacheMap value once ViewLock is acquired.
This avoids a really nasty race condition in our cache controler where
two concurrents could try to initialize cache on the same file.
This had two nasty effects: first shared map was purely leaked and erased
by the second one. And the private cache map, allocated on the first shared
cache map couldn't be freed and was leading to Mm BSOD (free in a middle of
a block).
This was often triggered while building ReactOS on ReactOS (with multi threads).
With that patch, I cannot crash anylonger while building ReactOS.
CORE-14634
---
ntoskrnl/cc/view.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c
index 9a7f716854..ee9d1e30d2 100644
--- a/ntoskrnl/cc/view.c
+++ b/ntoskrnl/cc/view.c
@@ -1391,12 +1391,12 @@ CcRosInitializeFileCache (
BOOLEAN Allocated;
PROS_SHARED_CACHE_MAP SharedCacheMap;
- SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
DPRINT("CcRosInitializeFileCache(FileObject 0x%p, SharedCacheMap 0x%p)\n",
FileObject, SharedCacheMap);
Allocated = FALSE;
KeAcquireGuardedMutex(&ViewLock);
+ SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
if (SharedCacheMap == NULL)
{
Allocated = TRUE;