[NTOSKRNL]

Do not use image base addresses above MmHighestUserAddress in MmMapViewOfSection, because it would first succeed when checking for conflicting memory areas, and thus not try to find a better address, but later fail in MmMapViewOfSegment, which cannot create a memory area in system space (only possible with MmKernelAddressSpace / PsIdleProcess).
See issue #5680 for more details.

svn path=/trunk/; revision=54096
This commit is contained in:
Timo Kreuzer 2011-10-12 19:26:45 +00:00
parent 2e7ccdc07c
commit a38e883762

View file

@ -87,7 +87,7 @@ MmMapViewOfArm3Section(IN PVOID SectionObject,
IN SECTION_INHERIT InheritDisposition, IN SECTION_INHERIT InheritDisposition,
IN ULONG AllocationType, IN ULONG AllocationType,
IN ULONG Protect); IN ULONG Protect);
// //
// PeFmtCreateSection depends on the following: // PeFmtCreateSection depends on the following:
// //
@ -1633,7 +1633,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
{ {
DPRINT1("MmRequestPageMemoryConsumer failed (Status %x)\n", Status); DPRINT1("MmRequestPageMemoryConsumer failed (Status %x)\n", Status);
} }
} }
else else
{ {
@ -1819,7 +1819,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
PMM_REGION Region; PMM_REGION Region;
ULONG Entry; ULONG Entry;
PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace); PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
DPRINT("MmAccessFaultSectionView(%x, %x, %x, %x)\n", AddressSpace, MemoryArea, Address, Locked); DPRINT("MmAccessFaultSectionView(%x, %x, %x, %x)\n", AddressSpace, MemoryArea, Address, Locked);
/* /*
@ -4626,6 +4626,12 @@ MmMapViewOfSection(IN PVOID SectionObject,
ImageSectionObject->ImageSize = (ULONG)ImageSize; ImageSectionObject->ImageSize = (ULONG)ImageSize;
/* Check for an illegal base address */
if ((ImageBase + ImageSize) > (ULONG_PTR)MmHighestUserAddress)
{
ImageBase = PAGE_ROUND_DOWN((ULONG_PTR)MmHighestUserAddress - ImageSize);
}
/* Check there is enough space to map the section at that point. */ /* Check there is enough space to map the section at that point. */
if (MmLocateMemoryAreaByRegion(AddressSpace, (PVOID)ImageBase, if (MmLocateMemoryAreaByRegion(AddressSpace, (PVOID)ImageBase,
PAGE_ROUND_UP(ImageSize)) != NULL) PAGE_ROUND_UP(ImageSize)) != NULL)