Skip to content

Commit 09f0680

Browse files
HeisSpiterJoachimHenze
authored andcommitted
[0.4.9] cherry-pick [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 (cherry picked from commit 8a8cb4d)
1 parent bf2d787 commit 09f0680

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ntoskrnl/cc/view.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,12 +1391,12 @@ CcRosInitializeFileCache (
13911391
BOOLEAN Allocated;
13921392
PROS_SHARED_CACHE_MAP SharedCacheMap;
13931393

1394-
SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
13951394
DPRINT("CcRosInitializeFileCache(FileObject 0x%p, SharedCacheMap 0x%p)\n",
13961395
FileObject, SharedCacheMap);
13971396

13981397
Allocated = FALSE;
13991398
KeAcquireGuardedMutex(&ViewLock);
1399+
SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
14001400
if (SharedCacheMap == NULL)
14011401
{
14021402
Allocated = TRUE;

0 commit comments

Comments
 (0)