https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3d8dd932b1d4f60344f37…
commit 3d8dd932b1d4f60344f372323ec353396bcdda9b
Author: George Bișoc <george.bisoc(a)reactos.org>
AuthorDate: Thu Apr 15 16:42:28 2021 +0200
Commit: George Bișoc <george.bisoc(a)reactos.org>
CommitDate: Sun Apr 18 13:56:37 2021 +0200
[NTOS:SE] Lock the token in SeQueryInformationToken and do some cleanup
* Guard the token in a lock whilst querying stuff
* Remove the piece of code that checks if the information class provided is above the maximum information class threshold. That code literally duplicates the inner functionality of the default case in the switch block, where the code falls in that case if an invalid information class is provided anyway.
* Remove the redundant information classes. Internally, this function in Windows has 12 switch case blocks (11 token info classes + the default case) and the other classes are supported in NtQueryInformationToken only so it doesn't make any logical sense to keep them in the codebase.
* Annotate the argument parameters with SAL and add documentation header
---
ntoskrnl/se/token.c | 126 +++++++++++++---------------------------------------
1 file changed, 32 insertions(+), 94 deletions(-)
diff --git a/ntoskrnl/se/token.c b/ntoskrnl/se/token.c
index 31601411b07..d38fe29517e 100644
--- a/ntoskrnl/se/token.c
+++ b/ntoskrnl/se/token.c
@@ -1685,17 +1685,37 @@ SeFilterToken(IN PACCESS_TOKEN ExistingToken,
return STATUS_NOT_IMPLEMENTED;
}
-/*
- * @implemented
+/**
+ * @brief
+ * Queries information details about the given token to the call. The difference
+ * between NtQueryInformationToken and this routine is that the system call has
+ * user mode buffer data probing and additional protection checks whereas this
+ * routine doesn't have any of these. The routine is used exclusively in kernel
+ * mode.
+ *
+ * @param[in] AccessToken
+ * An access token to be given.
*
- * NOTE: SeQueryInformationToken is just NtQueryInformationToken without all
- * the bells and whistles needed for user-mode buffer access protection.
+ * @param[in] TokenInformationClass
+ * Token information class.
+ *
+ * @param[out] TokenInformation
+ * Buffer with retrieved information. Such information is arbitrary, depending
+ * on the requested information class.
+ *
+ * @return
+ * Returns STATUS_SUCCESS if the operation to query the desired information
+ * has completed successfully. STATUS_INSUFFICIENT_RESOURCES is returned if
+ * pool memory allocation has failed to satisfy an operation. Otherwise
+ * STATUS_INVALID_INFO_CLASS is returned indicating that the information
+ * class provided is not supported by the routine.
*/
NTSTATUS
NTAPI
-SeQueryInformationToken(IN PACCESS_TOKEN AccessToken,
- IN TOKEN_INFORMATION_CLASS TokenInformationClass,
- OUT PVOID *TokenInformation)
+SeQueryInformationToken(
+ _In_ PACCESS_TOKEN AccessToken,
+ _In_ TOKEN_INFORMATION_CLASS TokenInformationClass,
+ _Outptr_result_buffer_(_Inexpressible_(token-dependent)) PVOID *TokenInformation)
{
NTSTATUS Status;
PTOKEN Token = (PTOKEN)AccessToken;
@@ -1708,13 +1728,8 @@ SeQueryInformationToken(IN PACCESS_TOKEN AccessToken,
PAGED_CODE();
- if (TokenInformationClass >= MaxTokenInfoClass)
- {
- DPRINT1("SeQueryInformationToken(%d) invalid information class\n", TokenInformationClass);
- return STATUS_INVALID_INFO_CLASS;
- }
-
- // TODO: Lock the token
+ /* Lock the token */
+ SepAcquireTokenLockShared(Token);
switch (TokenInformationClass)
{
@@ -2014,86 +2029,6 @@ SeQueryInformationToken(IN PACCESS_TOKEN AccessToken,
break;
}
-/*
- * The following 4 cases are only implemented in NtQueryInformationToken
- */
-#if 0
-
- case TokenOrigin:
- {
- PTOKEN_ORIGIN to;
-
- DPRINT("SeQueryInformationToken(TokenOrigin)\n");
- RequiredLength = sizeof(TOKEN_ORIGIN);
-
- /* Allocate the output buffer */
- to = ExAllocatePoolWithTag(PagedPool, RequiredLength, TAG_SE);
- if (to == NULL)
- {
- Status = STATUS_INSUFFICIENT_RESOURCES;
- break;
- }
-
- RtlCopyLuid(&to->OriginatingLogonSession,
- &Token->AuthenticationId);
-
- /* Return the structure */
- *TokenInformation = to;
- Status = STATUS_SUCCESS;
- break;
- }
-
- case TokenGroupsAndPrivileges:
- DPRINT1("SeQueryInformationToken(TokenGroupsAndPrivileges) not implemented\n");
- Status = STATUS_NOT_IMPLEMENTED;
- break;
-
- case TokenRestrictedSids:
- {
- PTOKEN_GROUPS tg = (PTOKEN_GROUPS)TokenInformation;
- ULONG SidLen;
- PSID Sid;
-
- DPRINT("SeQueryInformationToken(TokenRestrictedSids)\n");
- RequiredLength = sizeof(tg->GroupCount) +
- RtlLengthSidAndAttributes(Token->RestrictedSidCount, Token->RestrictedSids);
-
- SidLen = RequiredLength - sizeof(tg->GroupCount) -
- (Token->RestrictedSidCount * sizeof(SID_AND_ATTRIBUTES));
-
- /* Allocate the output buffer */
- tg = ExAllocatePoolWithTag(PagedPool, RequiredLength, TAG_SE);
- if (tg == NULL)
- {
- Status = STATUS_INSUFFICIENT_RESOURCES;
- break;
- }
-
- Sid = (PSID)((ULONG_PTR)tg + sizeof(tg->GroupCount) +
- (Token->RestrictedSidCount * sizeof(SID_AND_ATTRIBUTES)));
-
- tg->GroupCount = Token->RestrictedSidCount;
- Status = RtlCopySidAndAttributesArray(Token->RestrictedSidCount,
- Token->RestrictedSids,
- SidLen,
- &tg->Groups[0],
- Sid,
- &Unused.PSid,
- &Unused.Ulong);
-
- /* Return the structure */
- *TokenInformation = tg;
- Status = STATUS_SUCCESS;
- break;
- }
-
- case TokenSandBoxInert:
- DPRINT1("SeQueryInformationToken(TokenSandboxInert) not implemented\n");
- Status = STATUS_NOT_IMPLEMENTED;
- break;
-
-#endif
-
case TokenSessionId:
{
DPRINT("SeQueryInformationToken(TokenSessionId)\n");
@@ -2107,6 +2042,9 @@ SeQueryInformationToken(IN PACCESS_TOKEN AccessToken,
break;
}
+ /* Release the lock of the token */
+ SepReleaseTokenLock(Token);
+
return Status;
}
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3feb0cfb9fca759405f6b…
commit 3feb0cfb9fca759405f6ba434423f30c3214dc72
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sun Apr 11 14:25:08 2021 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Apr 18 13:40:30 2021 +0200
[CONFIGURE] Fix warnings shown when parsing cmdline
---
configure.cmd | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/configure.cmd b/configure.cmd
index 2d780760681..813fb48f2e3 100755
--- a/configure.cmd
+++ b/configure.cmd
@@ -87,8 +87,8 @@ REM Parse command line parameters
echo Please run this command in a [Developer] Command Prompt for Visual Studio.
goto quit
) else if /I "%1" NEQ "" (
- echo %1| find /I "-D" > NUL
- if %ERRORLEVEL% == 0 (
+ echo.%1| find /I "-D" >nul 2>&1
+ if not errorlevel 1 (
REM User is passing a switch to CMake
REM Ignore it, and ignore the next parameter that follows
Shift
@@ -123,8 +123,8 @@ REM Parse command line parameters
set CMAKE_ARCH=-A ARM
)
) else if /I "%1" NEQ "" (
- echo %1| find /I "-D" > NUL
- if %ERRORLEVEL% == 0 (
+ echo.%1| find /I "-D" >nul 2>&1
+ if not errorlevel 1 (
REM User is passing a switch to CMake
REM Ignore it, and ignore the next parameter that follows
Shift
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9e947e2b2be05d01590f4…
commit 9e947e2b2be05d01590f42741413b8b90f911071
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Fri Apr 16 23:45:08 2021 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Fri Apr 16 23:45:08 2021 +0200
[DEVMGR] Get rid of the unknown device class hack
Treat the unknown device class like any other device class.
CORE-17527
---
dll/win32/devmgr/devmgmt/DeviceView.cpp | 39 +++++----------------------------
1 file changed, 5 insertions(+), 34 deletions(-)
diff --git a/dll/win32/devmgr/devmgmt/DeviceView.cpp b/dll/win32/devmgr/devmgmt/DeviceView.cpp
index 1bb0fab7dee..a0906e1657a 100644
--- a/dll/win32/devmgr/devmgmt/DeviceView.cpp
+++ b/dll/win32/devmgr/devmgmt/DeviceView.cpp
@@ -351,23 +351,11 @@ CDeviceView::GetNextClass(
if (cr != CR_SUCCESS)
return false;
- // Check if this is the unknown class
- if (IsEqualGUID(*ClassGuid, GUID_DEVCLASS_UNKNOWN))
- {
- // Get device info for all devices
- *hDevInfo = SetupDiGetClassDevsW(NULL,
- NULL,
- NULL,
- DIGCF_ALLCLASSES);
- }
- else
- {
- // We only want the devices for this class
- *hDevInfo = SetupDiGetClassDevsW(ClassGuid,
- NULL,
- NULL,
- DIGCF_PRESENT);
- }
+ // We only want the devices for this class
+ *hDevInfo = SetupDiGetClassDevsW(ClassGuid,
+ NULL,
+ NULL,
+ DIGCF_PRESENT);
return (hDevInfo != INVALID_HANDLE_VALUE);
}
@@ -449,7 +437,6 @@ CDeviceView::ListDevicesByType()
bClassSuccess = GetNextClass(ClassIndex, &ClassGuid, &hDevInfo);
if (bClassSuccess)
{
- bool bClassUnknown = false;
bool AddedParent = false;
INT DeviceIndex = 0;
bool MoreItems = false;
@@ -462,10 +449,6 @@ CDeviceView::ListDevicesByType()
continue;
}
- // Set a flag is this is the (special case) unknown class
- if (IsEqualGUID(ClassGuid, GUID_DEVCLASS_UNKNOWN))
- bClassUnknown = true;
-
// Check if this is a hidden class
if (IsEqualGUID(ClassGuid, GUID_DEVCLASS_LEGACYDRIVER) ||
IsEqualGUID(ClassGuid, GUID_DEVCLASS_VOLUME))
@@ -494,18 +477,6 @@ CDeviceView::ListDevicesByType()
{
MoreItems = true;
- // The unknown class handle contains all devices on the system,
- // and we're just looking for the ones with a null GUID
- if (bClassUnknown)
- {
- if (IsEqualGUID(DeviceInfoData.ClassGuid, GUID_NULL) == FALSE)
- {
- // This is a known device, we aren't interested in it
- DeviceIndex++;
- continue;
- }
- }
-
// Get the cached device node
DeviceNode = GetDeviceNode(DeviceInfoData.DevInst);
if (DeviceNode == nullptr)