https://git.reactos.org/?p=reactos.git;a=commitdiff;h=70c62aa2c9e5b4bdabb05…
commit 70c62aa2c9e5b4bdabb05ac5b92f6c56ee166fac
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Wed Dec 2 12:39:58 2020 +0100
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Feb 3 09:41:22 2021 +0100
[NTOS:CC] Fix Vacb size usage & check
---
ntoskrnl/cc/view.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c
index 0e07eb7f1b6..de4a75ea8f7 100644
--- a/ntoskrnl/cc/view.c
+++ b/ntoskrnl/cc/view.c
@@ -388,7 +388,6 @@ CcRosMarkDirtyVacb (
{
KIRQL oldIrql;
PROS_SHARED_CACHE_MAP SharedCacheMap;
- ULONG Length = VACB_MAPPING_GRANULARITY;
SharedCacheMap = Vacb->SharedCacheMap;
@@ -398,12 +397,9 @@ CcRosMarkDirtyVacb (
ASSERT(!Vacb->Dirty);
InsertTailList(&DirtyVacbListHead, &Vacb->DirtyVacbListEntry);
-#if 0
- if (Vacb->FileOffset.QuadPart + Length >
SharedCacheMap->SectionSize.QuadPart)
- Length = SharedCacheMap->SectionSize.QuadPart - Vacb->FileOffset.QuadPart;
-#endif
- CcTotalDirtyPages += PAGE_ROUND_UP(Length) / PAGE_SIZE;
- Vacb->SharedCacheMap->DirtyPages += PAGE_ROUND_UP(Length) / PAGE_SIZE;
+ /* FIXME: There is no reason to account for the whole VACB. */
+ CcTotalDirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE;
+ Vacb->SharedCacheMap->DirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE;
CcRosVacbIncRefCount(Vacb);
/* Move to the tail of the LRU list */
@@ -430,7 +426,6 @@ CcRosUnmarkDirtyVacb (
{
KIRQL oldIrql;
PROS_SHARED_CACHE_MAP SharedCacheMap;
- ULONG Length = VACB_MAPPING_GRANULARITY;
SharedCacheMap = Vacb->SharedCacheMap;
@@ -447,12 +442,8 @@ CcRosUnmarkDirtyVacb (
RemoveEntryList(&Vacb->DirtyVacbListEntry);
InitializeListHead(&Vacb->DirtyVacbListEntry);
-#if 0
- if (Vacb->FileOffset.QuadPart + Length >
SharedCacheMap->SectionSize.QuadPart)
- Length = SharedCacheMap->SectionSize.QuadPart - Vacb->FileOffset.QuadPart;
-#endif
- CcTotalDirtyPages -= PAGE_ROUND_UP(Length) / PAGE_SIZE;
- Vacb->SharedCacheMap->DirtyPages -= PAGE_ROUND_UP(Length) / PAGE_SIZE;
+ CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
+ Vacb->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
CcRosVacbDecRefCount(Vacb);
@@ -718,8 +709,11 @@ CcRosEnsureVacbResident(
ASSERT((Offset + Length) <= VACB_MAPPING_GRANULARITY);
- if ((Vacb->FileOffset.QuadPart + Offset) >
Vacb->SharedCacheMap->FileSize.QuadPart)
+ if ((Vacb->FileOffset.QuadPart + Offset) >
Vacb->SharedCacheMap->SectionSize.QuadPart)
+ {
+ DPRINT1("Vacb read beyond the file size!\n");
return FALSE;
+ }
BaseAddress = (PVOID)((ULONG_PTR)Vacb->BaseAddress + Offset);