https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dea9c291abb77977eee9208d1b5be22d9f676a5d
commit dea9c291abb77977eee9208d1b5be22d9f676a5d Author: Pierre Schweitzer <pie...@reactos.org> AuthorDate: Sat Mar 24 18:02:20 2018 +0100 Commit: Pierre Schweitzer <pie...@reactos.org> CommitDate: Sat Mar 24 19:15:58 2018 +0100 [NTOSKRNL] Add a few asserts when mapping a VACB in kernel space Also, reset VACB content when returning it to the lookaside list CORE-14478 --- ntoskrnl/cc/view.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index f7e7f5f7c6..100e22bf9e 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -624,17 +624,20 @@ CcRosMapVacbInKernelSpace( ULONG i; NTSTATUS Status; ULONG_PTR NumberOfPages; + PVOID BaseAddress = NULL; /* Create a memory area. */ MmLockAddressSpace(MmGetKernelAddressSpace()); Status = MmCreateMemoryArea(MmGetKernelAddressSpace(), 0, // nothing checks for VACB mareas, so set to 0 - &Vacb->BaseAddress, + &BaseAddress, VACB_MAPPING_GRANULARITY, PAGE_READWRITE, (PMEMORY_AREA*)&Vacb->MemoryArea, 0, PAGE_SIZE); + ASSERT(Vacb->BaseAddress == NULL); + Vacb->BaseAddress = BaseAddress; MmUnlockAddressSpace(MmGetKernelAddressSpace()); if (!NT_SUCCESS(Status)) { @@ -644,6 +647,7 @@ CcRosMapVacbInKernelSpace( ASSERT(((ULONG_PTR)Vacb->BaseAddress % PAGE_SIZE) == 0); ASSERT((ULONG_PTR)Vacb->BaseAddress > (ULONG_PTR)MmSystemRangeStart); + ASSERT((ULONG_PTR)Vacb->BaseAddress + VACB_MAPPING_GRANULARITY - 1 > (ULONG_PTR)MmSystemRangeStart); /* Create a virtual mapping for this memory area */ NumberOfPages = BYTES_TO_PAGES(VACB_MAPPING_GRANULARITY); @@ -659,6 +663,11 @@ CcRosMapVacbInKernelSpace( KeBugCheck(MEMORY_MANAGEMENT); } + ASSERT(BaseAddress == Vacb->BaseAddress); + ASSERT(i * PAGE_SIZE < VACB_MAPPING_GRANULARITY); + ASSERT((ULONG_PTR)Vacb->BaseAddress + (i * PAGE_SIZE) >= (ULONG_PTR)BaseAddress); + ASSERT((ULONG_PTR)Vacb->BaseAddress + (i * PAGE_SIZE) > (ULONG_PTR)MmSystemRangeStart); + Status = MmCreateVirtualMapping(NULL, (PVOID)((ULONG_PTR)Vacb->BaseAddress + (i * PAGE_SIZE)), PAGE_READWRITE, @@ -951,6 +960,7 @@ CcRosInternalFreeVacb ( ASSERT(Vacb->PinCount == 0); ASSERT(Vacb->ReferenceCount == 0); + RtlFillMemory(Vacb, sizeof(Vacb), 0xfd); ExFreeToNPagedLookasideList(&VacbLookasideList, Vacb); return STATUS_SUCCESS; }