[NTOS:MM] Acquire PsLoadedModuleResource when walking PsLoadedModuleList. CORE-16449

This commit is contained in:
Thomas Faber 2020-10-15 13:42:13 +02:00
parent a30edc324e
commit ba9bf73d48
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
2 changed files with 7 additions and 3 deletions

View file

@ -1466,13 +1466,14 @@ MiFindInitializationCode(OUT PVOID *StartVa,
/* Assume failure */
*StartVa = NULL;
/* Acquire the necessary lock while we loop the list */
/* Acquire the necessary locks while we loop the list */
KeEnterCriticalRegion();
KeWaitForSingleObject(&MmSystemLoadLock,
WrVirtualMemory,
KernelMode,
FALSE,
NULL);
ExAcquireResourceExclusiveLite(&PsLoadedModuleResource, TRUE);
/* Loop all loaded modules */
NextEntry = PsLoadedModuleList.Flink;
@ -1620,7 +1621,8 @@ MiFindInitializationCode(OUT PVOID *StartVa,
NextEntry = NextEntry->Flink;
}
/* Release the lock and return */
/* Release the locks and return */
ExReleaseResourceLite(&PsLoadedModuleResource);
KeReleaseMutant(&MmSystemLoadLock, 1, FALSE, FALSE);
KeLeaveCriticalRegion();
}

View file

@ -273,7 +273,8 @@ MmInitSystem(IN ULONG Phase,
/* Initialize the balance set manager */
MmInitBsmThread();
/* Loop the boot loaded images */
/* Loop the boot loaded images (under lock) */
ExAcquireResourceExclusiveLite(&PsLoadedModuleResource, TRUE);
for (ListEntry = PsLoadedModuleList.Flink;
ListEntry != &PsLoadedModuleList;
ListEntry = ListEntry->Flink)
@ -284,6 +285,7 @@ MmInitSystem(IN ULONG Phase,
/* Set up the image protection */
MiWriteProtectSystemImage(DataTableEntry->DllBase);
}
ExReleaseResourceLite(&PsLoadedModuleResource);
return TRUE;
}