[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:
Sir Richard 2010-09-27 17:09:33 +00:00
parent f5f6cee1d0
commit 05ce063ebc

View file

@ -229,32 +229,18 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
//
while (PagesFound < PageCount)
{
//
// Do we have zeroed pages?
//
if (MmZeroedPageListHead.Total)
/* Grab a page */
Page = MiRemoveAnyPage(0);
if (Page == 0)
{
//
// 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
//
/* This is not good... hopefully we have at least SOME pages */
ASSERT(PagesFound);
break;
}
/* Grab the page entry for it */
Pfn1 = MiGetPfnEntry(Page);
//
// Make sure it's really free
//
@ -267,11 +253,6 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
Pfn1->u3.e1.EndOfAllocation = 1;
Pfn1->u3.e2.ReferenceCount = 1;
//
// Decrease available pages
//
MmAvailablePages--;
//
// Save it into the MDL
//
@ -303,6 +284,9 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
if (MiIsPfnInUse(Pfn1)) continue;
if ((Pfn1->u3.e1.PageLocation == ZeroedPageList) != LookForZeroedPages) continue;
/* Remove the page from the free or zero list */
MiUnlinkFreeOrZeroedPage(Pfn1);
//
// Sanity checks
//
@ -314,11 +298,6 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
Pfn1->u3.e2.ReferenceCount = 1;
Pfn1->u3.e1.StartOfAllocation = 1;
Pfn1->u3.e1.EndOfAllocation = 1;
//
// Decrease available pages
//
MmAvailablePages--;
//
// Save this page into the MDL