mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 08:03:01 +00:00
[NTOS]: Don't use dangerous MiRemoveHeadList in MDL page allocation, use MiRemoveAnyPage instead.
[NTOS]: Don't repurpose pages from the zero/free page list without actually unlinking the page first! This should fix even more corruptions. svn path=/trunk/; revision=48909
This commit is contained in:
parent
f5f6cee1d0
commit
05ce063ebc
1 changed files with 10 additions and 31 deletions
|
@ -229,32 +229,18 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
|
||||||
//
|
//
|
||||||
while (PagesFound < PageCount)
|
while (PagesFound < PageCount)
|
||||||
{
|
{
|
||||||
//
|
/* Grab a page */
|
||||||
// Do we have zeroed pages?
|
Page = MiRemoveAnyPage(0);
|
||||||
//
|
if (Page == 0)
|
||||||
if (MmZeroedPageListHead.Total)
|
|
||||||
{
|
{
|
||||||
//
|
/* This is not good... hopefully we have at least SOME pages */
|
||||||
// Grab a zero page
|
|
||||||
//
|
|
||||||
Pfn1 = MiRemoveHeadList(&MmZeroedPageListHead);
|
|
||||||
}
|
|
||||||
else if (MmFreePageListHead.Total)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Nope, grab an unzeroed page
|
|
||||||
//
|
|
||||||
Pfn1 = MiRemoveHeadList(&MmFreePageListHead);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// This is not good... hopefully we have at least SOME pages
|
|
||||||
//
|
|
||||||
ASSERT(PagesFound);
|
ASSERT(PagesFound);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Grab the page entry for it */
|
||||||
|
Pfn1 = MiGetPfnEntry(Page);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Make sure it's really free
|
// Make sure it's really free
|
||||||
//
|
//
|
||||||
|
@ -267,11 +253,6 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
|
||||||
Pfn1->u3.e1.EndOfAllocation = 1;
|
Pfn1->u3.e1.EndOfAllocation = 1;
|
||||||
Pfn1->u3.e2.ReferenceCount = 1;
|
Pfn1->u3.e2.ReferenceCount = 1;
|
||||||
|
|
||||||
//
|
|
||||||
// Decrease available pages
|
|
||||||
//
|
|
||||||
MmAvailablePages--;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Save it into the MDL
|
// Save it into the MDL
|
||||||
//
|
//
|
||||||
|
@ -303,6 +284,9 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
|
||||||
if (MiIsPfnInUse(Pfn1)) continue;
|
if (MiIsPfnInUse(Pfn1)) continue;
|
||||||
if ((Pfn1->u3.e1.PageLocation == ZeroedPageList) != LookForZeroedPages) continue;
|
if ((Pfn1->u3.e1.PageLocation == ZeroedPageList) != LookForZeroedPages) continue;
|
||||||
|
|
||||||
|
/* Remove the page from the free or zero list */
|
||||||
|
MiUnlinkFreeOrZeroedPage(Pfn1);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sanity checks
|
// Sanity checks
|
||||||
//
|
//
|
||||||
|
@ -314,11 +298,6 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
|
||||||
Pfn1->u3.e2.ReferenceCount = 1;
|
Pfn1->u3.e2.ReferenceCount = 1;
|
||||||
Pfn1->u3.e1.StartOfAllocation = 1;
|
Pfn1->u3.e1.StartOfAllocation = 1;
|
||||||
Pfn1->u3.e1.EndOfAllocation = 1;
|
Pfn1->u3.e1.EndOfAllocation = 1;
|
||||||
|
|
||||||
//
|
|
||||||
// Decrease available pages
|
|
||||||
//
|
|
||||||
MmAvailablePages--;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Save this page into the MDL
|
// Save this page into the MDL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue