Author: jgardou
Date: Sun Aug 28 21:07:51 2016
New Revision: 72497

URL: http://svn.reactos.org/svn/reactos?rev=72497&view=rev
Log:
[NTOS/MM]
 - Shuffle parameter chacks in NtMapViewOfSection to make kmtest pass more of 
them
 - Restore previously lost check on ZeroBits against 21. Use the architecture 
specific define
 - Better check for ZeroBits and ViewSize

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

Modified: trunk/reactos/ntoskrnl/mm/ARM3/section.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/section.c?rev=72497&r1=72496&r2=72497&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/section.c    [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/section.c    [iso-8859-1] Sun Aug 28 
21:07:51 2016
@@ -3550,14 +3550,40 @@
     }
     _SEH2_END;
 
+    /* Check for kernel-mode address */
+    if (SafeBaseAddress > MM_HIGHEST_VAD_ADDRESS)
+    {
+        DPRINT1("Kernel base not allowed\n");
+        return STATUS_INVALID_PARAMETER_3;
+    }
+
+    /* Check for range entering kernel-mode */
+    if (((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS - (ULONG_PTR)SafeBaseAddress) < 
SafeViewSize)
+    {
+        DPRINT1("Overflowing into kernel base not allowed\n");
+        return STATUS_INVALID_PARAMETER_3;
+    }
+
     /* Check for invalid zero bits */
-    if (ZeroBits && SafeBaseAddress)
-    {
-        if ((((ULONG_PTR)SafeBaseAddress << ZeroBits) >> ZeroBits) != 
(ULONG_PTR)SafeBaseAddress)
+    if (ZeroBits)
+    {
+        if (ZeroBits > MI_MAX_ZERO_BITS)
         {
             DPRINT1("Invalid zero bits\n");
             return STATUS_INVALID_PARAMETER_4;
         }
+
+        if ((((ULONG_PTR)SafeBaseAddress << ZeroBits) >> ZeroBits) != 
(ULONG_PTR)SafeBaseAddress)
+        {
+            DPRINT1("Invalid zero bits\n");
+            return STATUS_INVALID_PARAMETER_4;
+        }
+
+        if (((((ULONG_PTR)SafeBaseAddress + SafeViewSize) << ZeroBits) >> 
ZeroBits) != ((ULONG_PTR)SafeBaseAddress + SafeViewSize))
+        {
+            DPRINT1("Invalid zero bits\n");
+            return STATUS_INVALID_PARAMETER_4;
+        }
     }
 
     if (!(AllocationType & MEM_DOS_LIM))
@@ -3575,27 +3601,6 @@
            DPRINT("SectionOffset is not at 64-kilobyte address boundary.");
            return STATUS_MAPPED_ALIGNMENT;
         }
-    }
-
-    /* Check for kernel-mode address */
-    if (SafeBaseAddress > MM_HIGHEST_VAD_ADDRESS)
-    {
-        DPRINT1("Kernel base not allowed\n");
-        return STATUS_INVALID_PARAMETER_3;
-    }
-
-    /* Check for range entering kernel-mode */
-    if (((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS - (ULONG_PTR)SafeBaseAddress) < 
SafeViewSize)
-    {
-        DPRINT1("Overflowing into kernel base not allowed\n");
-        return STATUS_INVALID_PARAMETER_3;
-    }
-
-    /* Check for invalid zero bits */
-    if (((ULONG_PTR)SafeBaseAddress + SafeViewSize) > (0xFFFFFFFF >> 
ZeroBits)) // arch?
-    {
-        DPRINT1("Invalid zero bits\n");
-        return STATUS_INVALID_PARAMETER_4;
     }
 
     /* Reference the process */


Reply via email to