https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2a80ae2bb6fdb4135d412…
commit 2a80ae2bb6fdb4135d41244335caa2dadb6c8fa9
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Sep 23 10:31:01 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sun Sep 23 10:32:14 2018 +0200
[NTOSKRNL] Properly align VACB writes
Also simplify VACB reads alignment code.
Also add some sanity ASSERTs.
---
ntoskrnl/cc/copy.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c
index 78c6553d8a..4509e2e43b 100644
--- a/ntoskrnl/cc/copy.c
+++ b/ntoskrnl/cc/copy.c
@@ -81,7 +81,7 @@ NTAPI
CcReadVirtualAddress (
PROS_VACB Vacb)
{
- ULONG Size, Pages;
+ ULONG Size;
PMDL Mdl;
NTSTATUS Status;
IO_STATUS_BLOCK IoStatus;
@@ -95,10 +95,11 @@ CcReadVirtualAddress (
}
Size = LargeSize.LowPart;
- Pages = BYTES_TO_PAGES(Size);
- ASSERT(Pages * PAGE_SIZE <= VACB_MAPPING_GRANULARITY);
+ Size = ROUND_TO_PAGES(Size);
+ ASSERT(Size <= VACB_MAPPING_GRANULARITY);
+ ASSERT(Size > 0);
- Mdl = IoAllocateMdl(Vacb->BaseAddress, Pages * PAGE_SIZE, FALSE, FALSE, NULL);
+ Mdl = IoAllocateMdl(Vacb->BaseAddress, Size, FALSE, FALSE, NULL);
if (!Mdl)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -177,6 +178,10 @@ CcWriteVirtualAddress (
} while (++i < (Size >> PAGE_SHIFT));
}
+ Size = ROUND_TO_PAGES(Size);
+ ASSERT(Size <= VACB_MAPPING_GRANULARITY);
+ ASSERT(Size > 0);
+
Mdl = IoAllocateMdl(Vacb->BaseAddress, Size, FALSE, FALSE, NULL);
if (!Mdl)
{