[NTOS] Zero data unconditionally after segment end, unless section is created with SEC_RESERVE

Use a SEC_RESERVE section in Cc
This commit is contained in:
Jérôme Gardou
2020-12-11 15:29:35 +01:00
parent a52bc6d179
commit 30f71c7fc0
2 changed files with 13 additions and 7 deletions

View File

@@ -1286,7 +1286,7 @@ CcRosInitializeFileCache (
NULL,
&SharedCacheMap->SectionSize,
PAGE_READWRITE,
0,
SEC_RESERVE,
NULL,
FileObject);

View File

@@ -1208,7 +1208,8 @@ MiReadPage(PMEMORY_AREA MemoryArea,
Status = STATUS_SUCCESS;
}
if ((MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap) && ((SegOffset + PAGE_SIZE) > MemoryArea->SectionData.Segment->RawLength.QuadPart))
if (!MemoryArea->SectionData.Section->u.Flags.Reserve
&& ((SegOffset + PAGE_SIZE) > MemoryArea->SectionData.Segment->RawLength.QuadPart))
{
KIRQL OldIrql;
PUCHAR PageMap;
@@ -2209,6 +2210,8 @@ MmCreateDataFileSection(PSECTION *SectionObject,
if (AllocationAttributes & SEC_NO_CHANGE)
Section->u.Flags.NoChange = 1;
if (AllocationAttributes & SEC_RESERVE)
Section->u.Flags.Reserve = 1;
if (!GotFileHandle)
{
@@ -4832,13 +4835,16 @@ MmExtendSection(
PMM_SECTION_SEGMENT Segment = (PMM_SECTION_SEGMENT)Section->Segment;
Section->SizeOfSection = *NewSize;
MmLockSectionSegment(Segment);
if (Segment->RawLength.QuadPart < NewSize->QuadPart)
if (!Section->u.Flags.Reserve)
{
Segment->RawLength = *NewSize;
Segment->Length.QuadPart = (NewSize->QuadPart + PAGE_SIZE - 1) & ~((LONGLONG)PAGE_SIZE);
MmLockSectionSegment(Segment);
if (Segment->RawLength.QuadPart < NewSize->QuadPart)
{
Segment->RawLength = *NewSize;
Segment->Length.QuadPart = (NewSize->QuadPart + PAGE_SIZE - 1) & ~((LONGLONG)PAGE_SIZE);
}
MmUnlockSectionSegment(Segment);
}
MmUnlockSectionSegment(Segment);
}
return STATUS_SUCCESS;