https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a5ea259b2864b25b62bf1…
commit a5ea259b2864b25b62bf1bb4045c6961877a342a
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Tue Jun 1 10:32:12 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Mon Jun 7 17:04:18 2021 +0200
[NTOS:MM] Fix remnants of CORE-17587
---
ntoskrnl/mm/i386/page.c | 26 +++++++++++++++++---------
ntoskrnl/mm/section.c | 2 +-
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/ntoskrnl/mm/i386/page.c b/ntoskrnl/mm/i386/page.c
index 3e5f5797218..d15a9f74964 100644
--- a/ntoskrnl/mm/i386/page.c
+++ b/ntoskrnl/mm/i386/page.c
@@ -540,6 +540,10 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
/* Make sure our PDE is valid, and that everything is going fine */
if (Process == NULL)
{
+ /* We don't support this in legacy Mm for kernel mappings */
+ ASSERT(ProtectionMask != MM_WRITECOPY);
+ ASSERT(ProtectionMask != MM_EXECUTE_WRITECOPY);
+
if (Address < MmSystemRangeStart)
{
DPRINT1("NULL process given for user-mode mapping at %p\n",
Address);
@@ -567,14 +571,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
PointerPte = MiAddressToPte(Address);
- if (Address >= MmSystemRangeStart)
- {
- MI_MAKE_HARDWARE_PTE_KERNEL(&TempPte, PointerPte, ProtectionMask, Page);
- }
- else
- {
- MI_MAKE_HARDWARE_PTE_USER(&TempPte, PointerPte, ProtectionMask, Page);
- }
+ MI_MAKE_HARDWARE_PTE(&TempPte, PointerPte, ProtectionMask, Page);
Pte = InterlockedExchangePte(PointerPte, TempPte.u.Long);
/* There should not have been anything valid here */
@@ -710,7 +707,18 @@ MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect)
PointerPte = MiAddressToPte(Address);
- MI_MAKE_HARDWARE_PTE_USER(&TempPte, PointerPte, ProtectionMask,
PFN_FROM_PTE(PointerPte));
+ /* Sanity check */
+ ASSERT(PointerPte->u.Hard.Owner == 1);
+
+ TempPte.u.Long = 0;
+ TempPte.u.Hard.PageFrameNumber = PointerPte->u.Hard.PageFrameNumber;
+ TempPte.u.Long |= MmProtectToPteMask[ProtectionMask];
+ TempPte.u.Hard.Owner = 1;
+
+ /* Only set valid bit if we have to */
+ if ((ProtectionMask != MM_NOACCESS) && !FlagOn(ProtectionMask,
MM_GUARDPAGE))
+ TempPte.u.Hard.Valid = 1;
+
/* Keep dirty & accessed bits */
TempPte.u.Hard.Accessed = PointerPte->u.Hard.Accessed;
TempPte.u.Hard.Dirty = PointerPte->u.Hard.Dirty;
diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c
index 005e686e771..c6b618cdbf8 100644
--- a/ntoskrnl/mm/section.c
+++ b/ntoskrnl/mm/section.c
@@ -1474,7 +1474,7 @@ MmAlterViewAttributes(PMMSUPPORT AddressSpace,
* If we doing COW for this segment then check if the page is
* already private.
*/
- if (DoCOW && MmIsPagePresent(Process, Address))
+ if (DoCOW && (MmIsPagePresent(Process, Address) ||
MmIsDisabledPage(Process, Address)))
{
LARGE_INTEGER Offset;
ULONG_PTR Entry;