mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 19:55:41 +00:00
[NTOSKRNL] Add extra sanity checks for VACB lists.
We now always initialize list members from the VACB and make sure the list entry has properly been removed from the list before free. CORE-14349
This commit is contained in:
parent
b54e5c689c
commit
42df4683d7
2 changed files with 13 additions and 2 deletions
|
@ -238,6 +238,7 @@ CcPurgeCacheSection (
|
||||||
/* This VACB is in range, so unlink it and mark for free */
|
/* This VACB is in range, so unlink it and mark for free */
|
||||||
ASSERT(Refs == 1 || Vacb->Dirty);
|
ASSERT(Refs == 1 || Vacb->Dirty);
|
||||||
RemoveEntryList(&Vacb->VacbLruListEntry);
|
RemoveEntryList(&Vacb->VacbLruListEntry);
|
||||||
|
InitializeListHead(&Vacb->VacbLruListEntry);
|
||||||
if (Vacb->Dirty)
|
if (Vacb->Dirty)
|
||||||
{
|
{
|
||||||
CcRosUnmarkDirtyVacb(Vacb, FALSE);
|
CcRosUnmarkDirtyVacb(Vacb, FALSE);
|
||||||
|
@ -253,6 +254,7 @@ CcPurgeCacheSection (
|
||||||
Vacb = CONTAINING_RECORD(RemoveHeadList(&FreeList),
|
Vacb = CONTAINING_RECORD(RemoveHeadList(&FreeList),
|
||||||
ROS_VACB,
|
ROS_VACB,
|
||||||
CacheMapVacbListEntry);
|
CacheMapVacbListEntry);
|
||||||
|
InitializeListHead(&Vacb->CacheMapVacbListEntry);
|
||||||
CcRosVacbDecRefCount(Vacb);
|
CcRosVacbDecRefCount(Vacb);
|
||||||
CcRosInternalFreeVacb(Vacb);
|
CcRosInternalFreeVacb(Vacb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -375,6 +375,7 @@ retry:
|
||||||
|
|
||||||
RemoveEntryList(¤t->CacheMapVacbListEntry);
|
RemoveEntryList(¤t->CacheMapVacbListEntry);
|
||||||
RemoveEntryList(¤t->VacbLruListEntry);
|
RemoveEntryList(¤t->VacbLruListEntry);
|
||||||
|
InitializeListHead(¤t->VacbLruListEntry);
|
||||||
InsertHeadList(&FreeList, ¤t->CacheMapVacbListEntry);
|
InsertHeadList(&FreeList, ¤t->CacheMapVacbListEntry);
|
||||||
|
|
||||||
/* Calculate how many pages we freed for Mm */
|
/* Calculate how many pages we freed for Mm */
|
||||||
|
@ -413,6 +414,7 @@ retry:
|
||||||
current = CONTAINING_RECORD(current_entry,
|
current = CONTAINING_RECORD(current_entry,
|
||||||
ROS_VACB,
|
ROS_VACB,
|
||||||
CacheMapVacbListEntry);
|
CacheMapVacbListEntry);
|
||||||
|
InitializeListHead(¤t->CacheMapVacbListEntry);
|
||||||
CcRosVacbDecRefCount(current);
|
CcRosVacbDecRefCount(current);
|
||||||
CcRosInternalFreeVacb(current);
|
CcRosInternalFreeVacb(current);
|
||||||
}
|
}
|
||||||
|
@ -567,6 +569,7 @@ CcRosUnmarkDirtyVacb (
|
||||||
Vacb->Dirty = FALSE;
|
Vacb->Dirty = FALSE;
|
||||||
|
|
||||||
RemoveEntryList(&Vacb->DirtyVacbListEntry);
|
RemoveEntryList(&Vacb->DirtyVacbListEntry);
|
||||||
|
InitializeListHead(&Vacb->DirtyVacbListEntry);
|
||||||
CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
|
CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
|
||||||
Vacb->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
|
Vacb->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
|
||||||
CcRosVacbDecRefCount(Vacb);
|
CcRosVacbDecRefCount(Vacb);
|
||||||
|
@ -743,11 +746,12 @@ CcRosCreateVacb (
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
current->MappedCount = 0;
|
current->MappedCount = 0;
|
||||||
current->DirtyVacbListEntry.Flink = NULL;
|
|
||||||
current->DirtyVacbListEntry.Blink = NULL;
|
|
||||||
current->ReferenceCount = 0;
|
current->ReferenceCount = 0;
|
||||||
current->PinCount = 0;
|
current->PinCount = 0;
|
||||||
KeInitializeMutex(¤t->Mutex, 0);
|
KeInitializeMutex(¤t->Mutex, 0);
|
||||||
|
InitializeListHead(¤t->CacheMapVacbListEntry);
|
||||||
|
InitializeListHead(¤t->DirtyVacbListEntry);
|
||||||
|
InitializeListHead(¤t->VacbLruListEntry);
|
||||||
CcRosAcquireVacbLock(current, NULL);
|
CcRosAcquireVacbLock(current, NULL);
|
||||||
KeAcquireGuardedMutex(&ViewLock);
|
KeAcquireGuardedMutex(&ViewLock);
|
||||||
|
|
||||||
|
@ -988,6 +992,9 @@ CcRosInternalFreeVacb (
|
||||||
|
|
||||||
ASSERT(Vacb->PinCount == 0);
|
ASSERT(Vacb->PinCount == 0);
|
||||||
ASSERT(Vacb->ReferenceCount == 0);
|
ASSERT(Vacb->ReferenceCount == 0);
|
||||||
|
ASSERT(IsListEmpty(&Vacb->CacheMapVacbListEntry));
|
||||||
|
ASSERT(IsListEmpty(&Vacb->DirtyVacbListEntry));
|
||||||
|
ASSERT(IsListEmpty(&Vacb->VacbLruListEntry));
|
||||||
RtlFillMemory(Vacb, sizeof(Vacb), 0xfd);
|
RtlFillMemory(Vacb, sizeof(Vacb), 0xfd);
|
||||||
ExFreeToNPagedLookasideList(&VacbLookasideList, Vacb);
|
ExFreeToNPagedLookasideList(&VacbLookasideList, Vacb);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
@ -1109,6 +1116,7 @@ CcRosDeleteFileCache (
|
||||||
current = CONTAINING_RECORD(current_entry, ROS_VACB, CacheMapVacbListEntry);
|
current = CONTAINING_RECORD(current_entry, ROS_VACB, CacheMapVacbListEntry);
|
||||||
CcRosAcquireVacbLock(current, NULL);
|
CcRosAcquireVacbLock(current, NULL);
|
||||||
RemoveEntryList(¤t->VacbLruListEntry);
|
RemoveEntryList(¤t->VacbLruListEntry);
|
||||||
|
InitializeListHead(¤t->VacbLruListEntry);
|
||||||
if (current->Dirty)
|
if (current->Dirty)
|
||||||
{
|
{
|
||||||
KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql);
|
KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql);
|
||||||
|
@ -1133,6 +1141,7 @@ CcRosDeleteFileCache (
|
||||||
{
|
{
|
||||||
current_entry = RemoveTailList(&FreeList);
|
current_entry = RemoveTailList(&FreeList);
|
||||||
current = CONTAINING_RECORD(current_entry, ROS_VACB, CacheMapVacbListEntry);
|
current = CONTAINING_RECORD(current_entry, ROS_VACB, CacheMapVacbListEntry);
|
||||||
|
InitializeListHead(¤t->CacheMapVacbListEntry);
|
||||||
CcRosVacbDecRefCount(current);
|
CcRosVacbDecRefCount(current);
|
||||||
CcRosInternalFreeVacb(current);
|
CcRosInternalFreeVacb(current);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue