From 82cf6c2b069906f50bb1a24a921f451ce5338366 Mon Sep 17 00:00:00 2001 From: Oleg Dubinskiy Date: Wed, 7 Dec 2022 23:15:42 +0100 Subject: [PATCH] [NTOS:IO] Properly zero-initialize a file object created by IopParseDevice (#4931) Fix uninitialized kernel memory leakage for a case when a file object extension is appended. CORE-18711 --- ntoskrnl/io/iomgr/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/io/iomgr/file.c b/ntoskrnl/io/iomgr/file.c index 548c7f28db7..bfe11ab295b 100644 --- a/ntoskrnl/io/iomgr/file.c +++ b/ntoskrnl/io/iomgr/file.c @@ -857,7 +857,7 @@ IopParseDevice(IN PVOID ParseObject, } /* Clear the file object */ - RtlZeroMemory(FileObject, sizeof(FILE_OBJECT)); + RtlZeroMemory(FileObject, ObjectSize); /* Check if this is Synch I/O */ if (OpenPacket->CreateOptions & @@ -917,6 +917,7 @@ IopParseDevice(IN PVOID ParseObject, /* Make sure the file object knows it has an extension */ FileObject->Flags |= FO_FILE_OBJECT_HAS_EXTENSION; + /* Initialize file object extension */ FileObjectExtension = (PFILE_OBJECT_EXTENSION)(FileObject + 1); FileObject->FileObjectExtension = FileObjectExtension;