From 1f03a83d50d2419b9c4589bae15479e2deebdeee Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sun, 23 Apr 2017 09:38:45 +0000 Subject: [PATCH] [NTOS:MM] - In NtMapViewOfSection, check for address alignment after validating the handles. This fixes the tests from the previous commit, but is also necessary because information about the section object is necessary to avoid the alignment checks for physical memory sections. CORE-13113 svn path=/trunk/; revision=74391 --- reactos/ntoskrnl/mm/ARM3/section.c | 38 +++++++++++++++++------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/section.c b/reactos/ntoskrnl/mm/ARM3/section.c index 5977fda4a89..4d274ba7cfa 100644 --- a/reactos/ntoskrnl/mm/ARM3/section.c +++ b/reactos/ntoskrnl/mm/ARM3/section.c @@ -3661,23 +3661,6 @@ NtMapViewOfSection(IN HANDLE SectionHandle, } } - if (!(AllocationType & MEM_DOS_LIM)) - { - /* Check for non-allocation-granularity-aligned BaseAddress */ - if (SafeBaseAddress != ALIGN_DOWN_POINTER_BY(SafeBaseAddress, MM_VIRTMEM_GRANULARITY)) - { - DPRINT("BaseAddress is not at 64-kilobyte address boundary."); - return STATUS_MAPPED_ALIGNMENT; - } - - /* Do the same for the section offset */ - if (SafeSectionOffset.LowPart != ALIGN_DOWN_BY(SafeSectionOffset.LowPart, MM_VIRTMEM_GRANULARITY)) - { - DPRINT("SectionOffset is not at 64-kilobyte address boundary."); - return STATUS_MAPPED_ALIGNMENT; - } - } - /* Reference the process */ Status = ObReferenceObjectByHandle(ProcessHandle, PROCESS_VM_OPERATION, @@ -3700,6 +3683,27 @@ NtMapViewOfSection(IN HANDLE SectionHandle, return Status; } + if (!(AllocationType & MEM_DOS_LIM)) + { + /* Check for non-allocation-granularity-aligned BaseAddress */ + if (SafeBaseAddress != ALIGN_DOWN_POINTER_BY(SafeBaseAddress, MM_VIRTMEM_GRANULARITY)) + { + DPRINT("BaseAddress is not at 64-kilobyte address boundary."); + ObDereferenceObject(Section); + ObDereferenceObject(Process); + return STATUS_MAPPED_ALIGNMENT; + } + + /* Do the same for the section offset */ + if (SafeSectionOffset.LowPart != ALIGN_DOWN_BY(SafeSectionOffset.LowPart, MM_VIRTMEM_GRANULARITY)) + { + DPRINT("SectionOffset is not at 64-kilobyte address boundary."); + ObDereferenceObject(Section); + ObDereferenceObject(Process); + return STATUS_MAPPED_ALIGNMENT; + } + } + /* Now do the actual mapping */ Status = MmMapViewOfSection(Section, Process, -- 2.17.1