https://git.reactos.org/?p=reactos.git;a=commitdiff;h=12e8d7fe0e4e45f802ae5…
commit 12e8d7fe0e4e45f802ae5db29e755d5ad184d1a9
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Thu Aug 16 19:00:22 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Thu Aug 16 19:00:22 2018 +0200
[NTOSKRNL] Only allow page file on a few specific device types
---
ntoskrnl/mm/pagefile.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/ntoskrnl/mm/pagefile.c b/ntoskrnl/mm/pagefile.c
index 985557825f..0649f0f2c2 100644
--- a/ntoskrnl/mm/pagefile.c
+++ b/ntoskrnl/mm/pagefile.c
@@ -364,6 +364,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
SECURITY_DESCRIPTOR SecurityDescriptor;
PACL Dacl;
PWSTR Buffer;
+ DEVICE_TYPE DeviceType;
DPRINT("NtCreatePagingFile(FileName %wZ, MinimumSize %I64d)\n",
FileName, MinimumSize->QuadPart);
@@ -727,6 +728,17 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
return Status;
}
+ /* Only allow page file on a few device types */
+ DeviceType = IoGetRelatedDeviceObject(FileObject)->DeviceType;
+ if (DeviceType != FILE_DEVICE_DISK_FILE_SYSTEM && DeviceType !=
FILE_DEVICE_NETWORK_FILE_SYSTEM &&
+ DeviceType != FILE_DEVICE_DFS_VOLUME && DeviceType !=
FILE_DEVICE_DFS_FILE_SYSTEM)
+ {
+ ObDereferenceObject(FileObject);
+ ZwClose(FileHandle);
+ ExFreePoolWithTag(Buffer, TAG_MM);
+ return Status;
+ }
+
/* Deny page file creation on a floppy disk */
FsDeviceInfo.Characteristics = 0;
IoQueryVolumeInformation(FileObject, FileFsDeviceInformation, sizeof(FsDeviceInfo),
&FsDeviceInfo, &Count);