Author: tkreuzer
Date: Wed Oct 12 19:26:45 2011
New Revision: 54096

URL: http://svn.reactos.org/svn/reactos?rev=54096&view=rev
Log:
[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.

Modified:
    trunk/reactos/ntoskrnl/mm/section.c

Modified: trunk/reactos/ntoskrnl/mm/section.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=54096&r1=54095&r2=54096&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Wed Oct 12 19:26:45 2011
@@ -87,7 +87,7 @@
                        IN SECTION_INHERIT InheritDisposition,
                        IN ULONG AllocationType,
                        IN ULONG Protect);
-                       
+
 //
 // PeFmtCreateSection depends on the following:
 //
@@ -1633,7 +1633,7 @@
          {
             DPRINT1("MmRequestPageMemoryConsumer failed (Status %x)\n", 
Status);
          }
-                
+
       }
       else
       {
@@ -1819,7 +1819,7 @@
    PMM_REGION Region;
    ULONG Entry;
    PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
-    
+
    DPRINT("MmAccessFaultSectionView(%x, %x, %x, %x)\n", AddressSpace, 
MemoryArea, Address, Locked);
 
    /*
@@ -4625,6 +4625,12 @@
       }
 
       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. */
       if (MmLocateMemoryAreaByRegion(AddressSpace, (PVOID)ImageBase,


Reply via email to