https://git.reactos.org/?p=reactos.git;a=commitdiff;h=07e19a5e093ec44464031…
commit 07e19a5e093ec444640313baa4a71e5c1940d517
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Wed Nov 24 13:34:26 2021 +0100
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Wed Nov 24 13:34:26 2021 +0100
[NTOS:IO] Fail, if io completion port and an apc routine are used at the same time
Add checks to NtNotifyChangeDirectoryFile, NtLockFile, NtReadFile and NtWriteFile.
This fixes two ntdll tests.
---
ntoskrnl/io/iomgr/iofunc.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c
index b9bf75736f5..62fb626fa25 100644
--- a/ntoskrnl/io/iomgr/iofunc.c
+++ b/ntoskrnl/io/iomgr/iofunc.c
@@ -287,7 +287,7 @@ IopDeviceFsIoControl(IN HANDLE DeviceHandle,
&HandleInformation);
if (!NT_SUCCESS(Status)) return Status;
- /* Can't use an I/O completion port and an APC in the same time */
+ /* Can't use an I/O completion port and an APC at the same time */
if ((FileObject->CompletionContext) && (UserApcRoutine))
{
/* Fail */
@@ -1675,6 +1675,14 @@ NtNotifyChangeDirectoryFile(IN HANDLE FileHandle,
NULL);
if (!NT_SUCCESS(Status)) return Status;
+ /* Can't use an I/O completion port and an APC at the same time */
+ if ((FileObject->CompletionContext) && (ApcRoutine))
+ {
+ /* Fail */
+ ObDereferenceObject(FileObject);
+ return STATUS_INVALID_PARAMETER;
+ }
+
/* Check if we have an event handle */
if (EventHandle)
{
@@ -1793,6 +1801,14 @@ NtLockFile(IN HANDLE FileHandle,
/* Check if we're called from user mode */
if (PreviousMode != KernelMode)
{
+ /* Can't use an I/O completion port and an APC at the same time */
+ if ((FileObject->CompletionContext) && (ApcRoutine))
+ {
+ /* Fail */
+ ObDereferenceObject(FileObject);
+ return STATUS_INVALID_PARAMETER;
+ }
+
/* Must have either FILE_READ_DATA or FILE_WRITE_DATA access */
if (!(HandleInformation.GrantedAccess &
(FILE_WRITE_DATA | FILE_READ_DATA)))
@@ -2743,6 +2759,14 @@ NtReadFile(IN HANDLE FileHandle,
CapturedByteOffset = ProbeForReadLargeInteger(ByteOffset);
}
+ /* Can't use an I/O completion port and an APC at the same time */
+ if ((FileObject->CompletionContext) && (ApcRoutine))
+ {
+ /* Fail */
+ ObDereferenceObject(FileObject);
+ return STATUS_INVALID_PARAMETER;
+ }
+
/* Perform additional checks for non-cached file access */
if (FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING)
{
@@ -3796,6 +3820,14 @@ NtWriteFile(IN HANDLE FileHandle,
CapturedByteOffset = ProbeForReadLargeInteger(ByteOffset);
}
+ /* Can't use an I/O completion port and an APC at the same time */
+ if ((FileObject->CompletionContext) && (ApcRoutine))
+ {
+ /* Fail */
+ ObDereferenceObject(FileObject);
+ return STATUS_INVALID_PARAMETER;
+ }
+
/* Perform additional checks for non-cached file access */
if (FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING)
{