https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bf596690657198c8e1272a46c4a10c73a4ff9f67

commit bf596690657198c8e1272a46c4a10c73a4ff9f67
Author:     Pierre Schweitzer <[email protected]>
AuthorDate: Thu Oct 4 07:56:23 2018 +0200
Commit:     Pierre Schweitzer <[email protected]>
CommitDate: Thu Oct 4 07:56:23 2018 +0200

    [NTOSKRNL] On read/write, also check buffer respects device alignment 
requirements
---
 ntoskrnl/io/iomgr/iofunc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c
index f3ad7164c2..b90e73f5dc 100644
--- a/ntoskrnl/io/iomgr/iofunc.c
+++ b/ntoskrnl/io/iomgr/iofunc.c
@@ -2621,6 +2621,14 @@ NtReadFile(IN HANDLE FileHandle,
                     return STATUS_INVALID_PARAMETER;
                 }
 
+                /* Fail if buffer doesn't match alignment requirements */
+                if (((ULONG_PTR)Buffer & DeviceObject->AlignmentRequirement) 
!= 0)
+                {
+                    /* Release the file object and and fail */
+                    ObDereferenceObject(FileObject);
+                    return STATUS_INVALID_PARAMETER;
+                }
+
                 if (ByteOffset)
                 {
                     /* Fail if ByteOffset is not sector size aligned */
@@ -3650,6 +3658,14 @@ NtWriteFile(IN HANDLE FileHandle,
                     return STATUS_INVALID_PARAMETER;
                 }
 
+                /* Fail if buffer doesn't match alignment requirements */
+                if (((ULONG_PTR)Buffer & DeviceObject->AlignmentRequirement) 
!= 0)
+                {
+                    /* Release the file object and and fail */
+                    ObDereferenceObject(FileObject);
+                    return STATUS_INVALID_PARAMETER;
+                }
+
                 if (ByteOffset)
                 {
                     /* Fail if ByteOffset is not sector size aligned */

Reply via email to