https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a330b56787951d897eec0…
commit a330b56787951d897eec0706b4649a452f8ba623
Author: George Bișoc <george.bisoc(a)reactos.org>
AuthorDate: Mon May 3 15:46:35 2021 +0200
Commit: George Bișoc <george.bisoc(a)reactos.org>
CommitDate: Sun Jun 6 17:14:22 2021 +0200
[NTOS:PS] Enable alignment probing for thread/process information classes
In addition to that, here are some stuff done in this commit whilst testing:
- ICIF_QUERY_SIZE_VARIABLE and friends were badly misused, they should be used only
when an information class whose information length size is dyanmic and not fixed. By
removing such flags from erroneous classes, this fixes the STATUS_INFO_LENGTH_MISMATCH
testcases.
- Use CHAR instead of UCHAR for classes that do not need alignment probing, as every
other class in the table do, for the sake of consistency.
- ProcessEnableAlignmentFaultFixup uses BOOLEAN as type size, not CHAR. This fixes a
testcase failure on ROS.
- Check for information length size before proceeding further on querying the
process' cookie information.
- ProcessHandleTracing wants an alignment of a ULONG, not CHAR.
- Move PROCESS_LDT_INFORMATION and PROCESS_LDT_SIZE outside of NTOS_MODE_USER macro
case. This fixes a compilation issue when enabling the alignment probing. My mistake of
having them inside NTOS_MODE_USER case, sorry.
- On functions like NtQueryInformationThread and the Process equivalent, complete
probing is not done at the beginning of the function, complete probing including if the
buffer is writable alongside with datatype misalignment check that is. Instead such check
is done on each information class case basis. With that said, we have to explicitly tell
DefaultQueryInfoBufferCheck if we want a complete probing or not initially.
---
ntoskrnl/ex/event.c | 3 +-
ntoskrnl/ex/mutant.c | 3 +-
ntoskrnl/ex/sem.c | 3 +-
ntoskrnl/ex/timer.c | 3 +-
ntoskrnl/include/internal/probe.h | 18 ++++--
ntoskrnl/include/internal/ps_i.h | 112 +++++++++++++++++++-------------------
ntoskrnl/include/ntoskrnl.h | 3 +
ntoskrnl/io/iomgr/iocomp.c | 3 +-
ntoskrnl/ps/query.c | 89 +++++++++++++++---------------
ntoskrnl/se/token.c | 3 +-
sdk/include/ndk/pstypes.h | 24 ++++----
11 files changed, 141 insertions(+), 123 deletions(-)
diff --git a/ntoskrnl/ex/event.c b/ntoskrnl/ex/event.c
index 0f7d6d3bbd0..e30420f65bb 100644
--- a/ntoskrnl/ex/event.c
+++ b/ntoskrnl/ex/event.c
@@ -333,7 +333,8 @@ NtQueryEvent(IN HANDLE EventHandle,
EventInformationLength,
ReturnLength,
NULL,
- PreviousMode);
+ PreviousMode,
+ TRUE);
if(!NT_SUCCESS(Status))
{
/* Invalid buffers */
diff --git a/ntoskrnl/ex/mutant.c b/ntoskrnl/ex/mutant.c
index ff5772beff2..bab471c6173 100644
--- a/ntoskrnl/ex/mutant.c
+++ b/ntoskrnl/ex/mutant.c
@@ -243,7 +243,8 @@ NtQueryMutant(IN HANDLE MutantHandle,
MutantInformationLength,
ResultLength,
NULL,
- PreviousMode);
+ PreviousMode,
+ TRUE);
if(!NT_SUCCESS(Status))
{
DPRINT("NtQueryMutant() failed, Status: 0x%x\n", Status);
diff --git a/ntoskrnl/ex/sem.c b/ntoskrnl/ex/sem.c
index 8a1810d5db7..29c622814ff 100644
--- a/ntoskrnl/ex/sem.c
+++ b/ntoskrnl/ex/sem.c
@@ -239,7 +239,8 @@ NtQuerySemaphore(IN HANDLE SemaphoreHandle,
SemaphoreInformationLength,
ReturnLength,
NULL,
- PreviousMode);
+ PreviousMode,
+ TRUE);
if (!NT_SUCCESS(Status))
{
/* Invalid buffers */
diff --git a/ntoskrnl/ex/timer.c b/ntoskrnl/ex/timer.c
index 129881dc5d9..0ce7af03156 100644
--- a/ntoskrnl/ex/timer.c
+++ b/ntoskrnl/ex/timer.c
@@ -536,7 +536,8 @@ NtQueryTimer(IN HANDLE TimerHandle,
TimerInformationLength,
ReturnLength,
NULL,
- PreviousMode);
+ PreviousMode,
+ TRUE);
if (!NT_SUCCESS(Status)) return Status;
/* Get the Timer Object */
diff --git a/ntoskrnl/include/internal/probe.h b/ntoskrnl/include/internal/probe.h
index f02af658779..b819718f5ae 100644
--- a/ntoskrnl/include/internal/probe.h
+++ b/ntoskrnl/include/internal/probe.h
@@ -63,7 +63,8 @@ DefaultQueryInfoBufferCheck(ULONG Class,
ULONG BufferLength,
PULONG ReturnLength,
PULONG_PTR ReturnLengthPtr,
- KPROCESSOR_MODE PreviousMode)
+ KPROCESSOR_MODE PreviousMode,
+ BOOLEAN CompleteProbing)
{
NTSTATUS Status = STATUS_SUCCESS;
@@ -90,9 +91,18 @@ DefaultQueryInfoBufferCheck(ULONG Class,
{
if (Buffer != NULL)
{
- ProbeForWrite(Buffer,
- BufferLength,
- ClassList[Class].AlignmentQUERY);
+ if (!CompleteProbing)
+ {
+ ProbeForRead(Buffer,
+ BufferLength,
+ ClassList[Class].AlignmentQUERY);
+ }
+ else
+ {
+ ProbeForWrite(Buffer,
+ BufferLength,
+ ClassList[Class].AlignmentQUERY);
+ }
}
if (ReturnLength != NULL)
diff --git a/ntoskrnl/include/internal/ps_i.h b/ntoskrnl/include/internal/ps_i.h
index 0f0a58e968f..85de26d8814 100644
--- a/ntoskrnl/include/internal/ps_i.h
+++ b/ntoskrnl/include/internal/ps_i.h
@@ -19,7 +19,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
PROCESS_BASIC_INFORMATION,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ProcessQuotaLimits */
@@ -27,7 +27,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
QUOTA_LIMITS,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ProcessIoCounters */
@@ -35,7 +35,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
IO_COUNTERS,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ProcessVmCounters */
@@ -51,7 +51,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
KERNEL_USER_TIMES,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ProcessBasePriority */
@@ -59,7 +59,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
KPRIORITY,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ProcessRaisePriority */
@@ -67,7 +67,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
ULONG,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ProcessDebugPort */
@@ -75,7 +75,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
HANDLE,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ProcessExceptionPort */
@@ -83,7 +83,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
HANDLE,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ProcessAccessToken */
@@ -91,7 +91,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
PROCESS_ACCESS_TOKEN,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ProcessLdtInformation */
@@ -99,7 +99,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
PROCESS_LDT_INFORMATION,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ProcessLdtSize */
@@ -107,7 +107,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
PROCESS_LDT_SIZE,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ProcessDefaultHardErrorMode */
@@ -115,7 +115,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ProcessIoPortHandlers */
@@ -123,7 +123,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
UCHAR,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ProcessPooledUsageAndLimits */
@@ -131,7 +131,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
POOLED_USAGE_AND_LIMITS,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ProcessWorkingSetWatch */
@@ -139,7 +139,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
PROCESS_WS_WATCH_INFORMATION,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET | ICIF_SET_SIZE_VARIABLE
),
/* ProcessUserModeIOPL */
@@ -147,17 +147,17 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
UCHAR,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ProcessEnableAlignmentFaultFixup */
IQS
(
- CHAR,
+ BOOLEAN,
CHAR,
BOOLEAN,
- UCHAR,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ CHAR,
+ ICIF_SET
),
/* ProcessPriorityClass */
@@ -167,7 +167,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
ULONG,
PROCESS_PRIORITY_CLASS,
CHAR,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ProcessWx86Information */
@@ -175,7 +175,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ProcessHandleCount */
@@ -183,7 +183,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ProcessAffinityMask */
@@ -191,7 +191,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
KAFFINITY,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ProcessPriorityBoost */
@@ -199,7 +199,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ProcessDeviceMap */
@@ -209,7 +209,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
ULONG,
RTL_FIELD_TYPE(PROCESS_DEVICEMAP_INFORMATION, Set),
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ProcessSessionInformation */
@@ -217,7 +217,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
PROCESS_SESSION_INFORMATION,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ProcessForegroundInformation */
@@ -226,8 +226,8 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
CHAR,
CHAR,
BOOLEAN,
- UCHAR,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ CHAR,
+ ICIF_SET
),
/* ProcessWow64Information */
@@ -235,7 +235,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ProcessImageFileName */
@@ -251,7 +251,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ProcessBreakOnTermination */
@@ -259,7 +259,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ProcessDebugObjectHandle */
@@ -267,7 +267,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
HANDLE,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ProcessDebugFlags */
@@ -275,17 +275,17 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ProcessHandleTracing */
IQS
(
PROCESS_HANDLE_TRACING_QUERY,
- CHAR,
ULONG,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ULONG,
+ ICIF_QUERY | ICIF_SET
),
/* ProcessIoPriority */
@@ -301,7 +301,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ProcessTlsInformation */
@@ -317,7 +317,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ProcessImageInformation */
@@ -325,7 +325,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
(
SECTION_IMAGE_INFORMATION,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ProcessCycleTime */
@@ -411,7 +411,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
THREAD_BASIC_INFORMATION,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ThreadTimes */
@@ -419,7 +419,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
KERNEL_USER_TIMES,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ThreadPriority */
@@ -427,7 +427,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
KPRIORITY,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ThreadBasePriority */
@@ -435,7 +435,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
LONG,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ThreadAffinityMask */
@@ -443,7 +443,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
KAFFINITY,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ThreadImpersonationToken */
@@ -451,7 +451,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
HANDLE,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ThreadDescriptorTableEntry is only implemented in x86 as well as the descriptor
entry */
@@ -461,7 +461,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
DESCRIPTOR_TABLE_ENTRY,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
#else
IQS_NONE,
@@ -474,7 +474,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
CHAR,
BOOLEAN,
UCHAR,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ThreadEventPair_Reusable */
@@ -492,7 +492,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
ULONG,
ULONG_PTR,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ThreadZeroTlsCell */
@@ -500,7 +500,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
ULONG_PTR,
ULONG,
- ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_SET
),
/* ThreadPerformanceCount */
@@ -508,7 +508,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
LARGE_INTEGER,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ThreadAmILastThread */
@@ -516,7 +516,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ThreadIdealProcessor */
@@ -524,7 +524,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
ULONG_PTR,
ULONG,
- ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_SET
),
/* ThreadPriorityBoost */
@@ -534,7 +534,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
ULONG,
ULONG_PTR,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ThreadSetTlsArrayAddress */
@@ -550,7 +550,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ThreadHideFromDebugger */
@@ -566,7 +566,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_SET | ICIF_SIZE_VARIABLE
+ ICIF_QUERY | ICIF_SET
),
/* ThreadSwitchLegacyState */
@@ -574,7 +574,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
ULONG,
ULONG,
- ICIF_SET | ICIF_SET_SIZE_VARIABLE
+ ICIF_SET
),
/* ThreadIsTerminated */
@@ -582,7 +582,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
(
ULONG,
ULONG,
- ICIF_QUERY | ICIF_QUERY_SIZE_VARIABLE
+ ICIF_QUERY
),
/* ThreadLastSystemCall */
diff --git a/ntoskrnl/include/ntoskrnl.h b/ntoskrnl/include/ntoskrnl.h
index a6ac78b4827..643562e60f0 100644
--- a/ntoskrnl/include/ntoskrnl.h
+++ b/ntoskrnl/include/ntoskrnl.h
@@ -124,6 +124,9 @@ C_ASSERT(MAX_WIN32_PATH == MAX_PATH);
#include "internal/probe.h"
#include "resource.h"
+/* Internal Ps alignment probing header */
+#include "internal/ps_i.h"
+
#ifdef _MSC_VER
# pragma section("INITDATA", read,write,discard)
#endif
diff --git a/ntoskrnl/io/iomgr/iocomp.c b/ntoskrnl/io/iomgr/iocomp.c
index df883d476a5..41457a66574 100644
--- a/ntoskrnl/io/iomgr/iocomp.c
+++ b/ntoskrnl/io/iomgr/iocomp.c
@@ -399,7 +399,8 @@ NtQueryIoCompletion(IN HANDLE IoCompletionHandle,
IoCompletionInformationLength,
ResultLength,
NULL,
- PreviousMode);
+ PreviousMode,
+ TRUE);
if (!NT_SUCCESS(Status)) return Status;
/* Get the Object */
diff --git a/ntoskrnl/ps/query.c b/ntoskrnl/ps/query.c
index 895c2db5d0d..5c28b03d068 100644
--- a/ntoskrnl/ps/query.c
+++ b/ntoskrnl/ps/query.c
@@ -86,26 +86,20 @@ NtQueryInformationProcess(
ULONG Flags;
PAGED_CODE();
- /* Check for user-mode caller */
- if (PreviousMode != KernelMode)
+ /* Verify Information Class validity */
+ Status = DefaultQueryInfoBufferCheck(ProcessInformationClass,
+ PsProcessInfoClass,
+ RTL_NUMBER_OF(PsProcessInfoClass),
+ ProcessInformation,
+ ProcessInformationLength,
+ ReturnLength,
+ NULL,
+ PreviousMode,
+ FALSE);
+ if (!NT_SUCCESS(Status))
{
- /* Prepare to probe parameters */
- _SEH2_TRY
- {
- /* Probe the buffer */
- ProbeForRead(ProcessInformation,
- ProcessInformationLength,
- sizeof(ULONG));
-
- /* Probe the return length if required */
- if (ReturnLength) ProbeForWriteUlong(ReturnLength);
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
- }
- _SEH2_END;
+ DPRINT1("NtQueryInformationProcess(): Information verification class failed!
(Status -> 0x%lx, ProcessInformationClass -> %lx)\n", Status,
ProcessInformationClass);
+ return Status;
}
if (((ProcessInformationClass == ProcessCookie) ||
@@ -794,6 +788,13 @@ NtQueryInformationProcess(
/* Per-process security cookie */
case ProcessCookie:
+ if (ProcessInformationLength != sizeof(ULONG))
+ {
+ /* Length size wrong, bail out */
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
/* Get the current process and cookie */
Process = PsGetCurrentProcess();
Cookie = Process->Cookie;
@@ -1131,15 +1132,17 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
PAGED_CODE();
/* Verify Information Class validity */
-#if 0
Status = DefaultSetInfoBufferCheck(ProcessInformationClass,
PsProcessInfoClass,
RTL_NUMBER_OF(PsProcessInfoClass),
ProcessInformation,
ProcessInformationLength,
PreviousMode);
- if (!NT_SUCCESS(Status)) return Status;
-#endif
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtSetInformationProcess(): Information verification class failed!
(Status -> 0x%lx, ProcessInformationClass -> %lx)\n", Status,
ProcessInformationClass);
+ return Status;
+ }
/* Check what class this is */
Access = PROCESS_SET_INFORMATION;
@@ -1846,7 +1849,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
case ProcessEnableAlignmentFaultFixup:
/* Check buffer length */
- if (ProcessInformationLength != sizeof(ULONG))
+ if (ProcessInformationLength != sizeof(BOOLEAN))
{
Status = STATUS_INFO_LENGTH_MISMATCH;
break;
@@ -2036,15 +2039,17 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
PAGED_CODE();
/* Verify Information Class validity */
-#if 0
Status = DefaultSetInfoBufferCheck(ThreadInformationClass,
PsThreadInfoClass,
RTL_NUMBER_OF(PsThreadInfoClass),
ThreadInformation,
ThreadInformationLength,
PreviousMode);
- if (!NT_SUCCESS(Status)) return Status;
-#endif
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtSetInformationThread(): Information verification class failed!
(Status -> 0x%lx, ThreadInformationClass -> %lx)\n", Status,
ThreadInformationClass);
+ return Status;
+ }
/* Check what kind of information class this is */
switch (ThreadInformationClass)
@@ -2634,26 +2639,20 @@ NtQueryInformationThread(IN HANDLE ThreadHandle,
ULONG ThreadTerminated;
PAGED_CODE();
- /* Check if we were called from user mode */
- if (PreviousMode != KernelMode)
+ /* Verify Information Class validity */
+ Status = DefaultQueryInfoBufferCheck(ThreadInformationClass,
+ PsThreadInfoClass,
+ RTL_NUMBER_OF(PsThreadInfoClass),
+ ThreadInformation,
+ ThreadInformationLength,
+ ReturnLength,
+ NULL,
+ PreviousMode,
+ FALSE);
+ if (!NT_SUCCESS(Status))
{
- /* Enter SEH */
- _SEH2_TRY
- {
- /* Probe the buffer */
- ProbeForWrite(ThreadInformation,
- ThreadInformationLength,
- sizeof(ULONG));
-
- /* Probe the return length if required */
- if (ReturnLength) ProbeForWriteUlong(ReturnLength);
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
- }
- _SEH2_END;
+ DPRINT1("NtQueryInformationThread(): Information verification class failed!
(Status -> 0x%lx , ThreadInformationClass -> %lx)\n", Status,
ThreadInformationClass);
+ return Status;
}
/* Check what class this is */
diff --git a/ntoskrnl/se/token.c b/ntoskrnl/se/token.c
index eb67cda7486..256e4b31d4c 100644
--- a/ntoskrnl/se/token.c
+++ b/ntoskrnl/se/token.c
@@ -2400,7 +2400,8 @@ NtQueryInformationToken(
TokenInformationLength,
ReturnLength,
NULL,
- PreviousMode);
+ PreviousMode,
+ TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT("NtQueryInformationToken() failed, Status: 0x%x\n", Status);
diff --git a/sdk/include/ndk/pstypes.h b/sdk/include/ndk/pstypes.h
index 53e76516eed..3a47b04a560 100644
--- a/sdk/include/ndk/pstypes.h
+++ b/sdk/include/ndk/pstypes.h
@@ -911,18 +911,6 @@ typedef struct _POOLED_USAGE_AND_LIMITS
SIZE_T PagefileLimit;
} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
-typedef struct _PROCESS_LDT_INFORMATION
-{
- ULONG Start;
- ULONG Length;
- LDT_ENTRY LdtEntries[ANYSIZE_ARRAY];
-} PROCESS_LDT_INFORMATION, *PPROCESS_LDT_INFORMATION;
-
-typedef struct _PROCESS_LDT_SIZE
-{
- ULONG Length;
-} PROCESS_LDT_SIZE, *PPROCESS_LDT_SIZE;
-
typedef struct _PROCESS_WS_WATCH_INFORMATION
{
PVOID FaultingPc;
@@ -951,6 +939,18 @@ typedef struct _PROCESS_HANDLE_TRACING_QUERY
#endif
+typedef struct _PROCESS_LDT_INFORMATION
+{
+ ULONG Start;
+ ULONG Length;
+ LDT_ENTRY LdtEntries[ANYSIZE_ARRAY];
+} PROCESS_LDT_INFORMATION, *PPROCESS_LDT_INFORMATION;
+
+typedef struct _PROCESS_LDT_SIZE
+{
+ ULONG Length;
+} PROCESS_LDT_SIZE, *PPROCESS_LDT_SIZE;
+
typedef struct _PROCESS_PRIORITY_CLASS
{
BOOLEAN Foreground;