https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b076800dd8518cd5be25a…
commit b076800dd8518cd5be25a3b59fc63f2cd79d0bbf
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Oct 23 19:59:08 2022 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Tue Nov 8 23:47:02 2022 +0100
[SMSS] Fix the displayed subsystem name in the failure path of SmpSbCreateSession().
The SubSystemNames array didn't correlate with the possible values of
SubSystemType (e.g. index 4 was "Posix" whereas Posix is type 7; Posix
and OS/2 entries were inverted; Windows CUI subsystem (type 3) was
mapped to "Posix"), and the array dereferencing was out of bounds if the
SubSystemType of the image happened to be larger than 8.
I know (strings extraction from debug build of Windows' SMSS.EXE) that
they use that same old'n'broken array. Perhaps a leftover from very old
times (NT 3.1 betas) where the PE format was under work and the
subsystem numbers didn't have their definitive values... (This has
already happened with the NT PDK v1.196 from September 1991.)
---
base/system/smss/smsbapi.c | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/base/system/smss/smsbapi.c b/base/system/smss/smsbapi.c
index 0cd49e1ed19..1eed513601c 100644
--- a/base/system/smss/smsbapi.c
+++ b/base/system/smss/smsbapi.c
@@ -15,14 +15,19 @@
/* GLOBALS ********************************************************************/
-PCHAR SmpSubSystemNames[] =
+#if DBG
+const PCSTR SmpSubSystemNames[] =
{
"Unknown",
"Native",
- "Windows",
- "Posix",
- "OS/2"
+ "Windows GUI",
+ "Windows CUI",
+ NULL,
+ "OS/2 CUI"
+ NULL,
+ "Posix CUI"
};
+#endif
/* FUNCTIONS ******************************************************************/
@@ -35,6 +40,7 @@ SmpSbCreateSession(IN PVOID Reserved,
IN PCLIENT_ID DbgClientId)
{
NTSTATUS Status;
+ ULONG SubSystemType = ProcessInformation->ImageInformation.SubSystemType;
PSMP_SUBSYSTEM KnownSubsys;
SB_API_MSG SbApiMsg;
ULONG SessionId;
@@ -65,9 +71,7 @@ SmpSbCreateSession(IN PVOID Reserved,
}
/* Find the subsystem we have for this initial process */
- KnownSubsys = SmpLocateKnownSubSysByType(MuSessionId,
- ProcessInformation->
- ImageInformation.SubSystemType);
+ KnownSubsys = SmpLocateKnownSubSysByType(MuSessionId, SubSystemType);
if (KnownSubsys)
{
/* Duplicate the process handle into the message */
@@ -142,11 +146,22 @@ SmpSbCreateSession(IN PVOID Reserved,
}
/* If we don't yet have a subsystem, only native images can be launched */
- if (ProcessInformation->ImageInformation.SubSystemType != IMAGE_SUBSYSTEM_NATIVE)
+ if (SubSystemType != IMAGE_SUBSYSTEM_NATIVE)
{
/* Fail */
- DPRINT1("SMSS: %s SubSystem has not been started.\n",
- SmpSubSystemNames[ProcessInformation->ImageInformation.SubSystemType]);
+#if DBG
+ PCSTR SubSysName = NULL;
+ CHAR SubSysTypeName[sizeof("Type 0x")+8];
+
+ if (SubSystemType < RTL_NUMBER_OF(SmpSubSystemNames))
+ SubSysName = SmpSubSystemNames[SubSystemType];
+ if (!SubSysName)
+ {
+ SubSysName = SubSysTypeName;
+ sprintf(SubSysTypeName, "Type 0x%08x", SubSystemType);
+ }
+ DPRINT1("SMSS: %s SubSystem not found (either not started or destroyed).\n", SubSysName);
+#endif
Status = STATUS_UNSUCCESSFUL;
NtClose(ProcessInformation->ProcessHandle);
NtClose(ProcessInformation->ThreadHandle);
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bcbfcd22788e5321ef09e…
commit bcbfcd22788e5321ef09e7b00079fa8a453b2fa0
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Oct 23 23:54:06 2022 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Tue Nov 8 23:46:32 2022 +0100
[CSRSRV] Minimally-adapt CSRSRV to make it able to host other subsystems than Win32.
This is really ReactOS-specific, so I surround them with __REACTOS__
(even if this is our code) to differentiate these from Win2k3 behaviour,
even though they were strongly inspired by what was possible in the beta
versions of NT 3.1 (pre-3.10.404).
Interestingly, Windows 7+ partially re-introduced that functionality
(just in differencing "Windows=On" from "Off").
See https://reactos.org/wiki/User:Hbelusca/CSRSS for more information.
---
subsystems/csr/csrsrv/init.c | 57 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 54 insertions(+), 3 deletions(-)
diff --git a/subsystems/csr/csrsrv/init.c b/subsystems/csr/csrsrv/init.c
index 69e9cfdea00..491a15d896a 100644
--- a/subsystems/csr/csrsrv/init.c
+++ b/subsystems/csr/csrsrv/init.c
@@ -31,6 +31,10 @@ PCSR_THREAD CsrSbApiRequestThreadPtr;
HANDLE CsrSmApiPort = NULL;
HANDLE hSbApiPort = NULL;
HANDLE CsrApiPort = NULL;
+#ifdef __REACTOS__
+BOOLEAN CsrWindowsControl;
+ULONG CsrSubSystemType; // Known as SessionFirstProcessImageType in Windows 7+
+#endif
ULONG CsrMaxApiRequestThreads;
ULONG CsrTotalPerProcessDataLength;
ULONG SessionId;
@@ -559,6 +563,10 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
/* Set the Defaults */
CsrTotalPerProcessDataLength = 0;
CsrObjectDirectory = NULL;
+#ifdef __REACTOS__
+ CsrWindowsControl = FALSE;
+ CsrSubSystemType = IMAGE_SUBSYSTEM_UNKNOWN;
+#endif
CsrMaxApiRequestThreads = 16;
/* Save our Session ID, and create a Directory for it */
@@ -619,7 +627,36 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
}
else if (_stricmp(ParameterName, "SubSystemType") == 0)
{
+#ifdef __REACTOS__
+ /* Well-known subsystems, specified by names */
+ if (_stricmp(ParameterValue, "windows") == 0)
+ {
+ /* Behaviour compatible with Windows 7+ */
+ if (CsrWindowsControl)
+ CsrSubSystemType = IMAGE_SUBSYSTEM_WINDOWS_GUI;
+ else
+ CsrSubSystemType = IMAGE_SUBSYSTEM_WINDOWS_CUI;
+ }
+ else if (_stricmp(ParameterValue, "posix") == 0)
+ {
+ CsrSubSystemType = IMAGE_SUBSYSTEM_POSIX_CUI;
+ }
+ else if (_stricmp(ParameterValue, "os2") == 0)
+ {
+ CsrSubSystemType = IMAGE_SUBSYSTEM_OS2_CUI;
+ }
+ else if (_stricmp(ParameterValue, "native") == 0)
+ {
+ CsrSubSystemType = IMAGE_SUBSYSTEM_NATIVE;
+ }
+ else
+ {
+ /* Another subsystem type, specified by a numerical value */
+ Status = RtlCharToInteger(ParameterValue, 0, &CsrSubSystemType);
+ }
+#else
/* Ignored */
+#endif
}
else if (_stricmp(ParameterName, "MaxRequestThreads") == 0)
{
@@ -634,7 +671,7 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
}
else if (_stricmp(ParameterName, "ProfileControl") == 0)
{
- /* Ignored */
+ /* Related functionality ignored since NT 3.5 */
}
else if (_stricmp(ParameterName, "SharedSection") == 0)
{
@@ -661,7 +698,7 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
/* Check for the Entry Point */
if ((*ServerString == ':') && (!EntryPoint))
{
- /* Found it. Add a nullchar and save it */
+ /* Found it. NULL-terminate and save it. */
*ServerString++ = ANSI_NULL;
EntryPoint = ServerString;
}
@@ -696,8 +733,11 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
}
else if (_stricmp(ParameterName, "Windows") == 0)
{
+#ifdef __REACTOS__
+ CsrWindowsControl = (_stricmp(ParameterValue, "On") == 0);
+#else
/* Ignored */
- // Check whether we want to start in pure GUI or pure CLI.
+#endif
}
else
{
@@ -1042,6 +1082,10 @@ CsrServerInitialization(IN ULONG ArgumentCount,
return Status;
}
+#ifdef __REACTOS__
+ if (CsrSubSystemType != IMAGE_SUBSYSTEM_UNKNOWN)
+ {
+#endif
/* Initialize the API Port for SM communication */
Status = CsrSbApiPortInitialize();
if (!NT_SUCCESS(Status))
@@ -1054,7 +1098,11 @@ CsrServerInitialization(IN ULONG ArgumentCount,
/* We're all set! Connect to SM! */
Status = SmConnectToSm(&CsrSbApiPortName,
CsrSbApiPort,
+#ifdef __REACTOS__
+ CsrSubSystemType,
+#else
IMAGE_SUBSYSTEM_WINDOWS_GUI,
+#endif
&CsrSmApiPort);
if (!NT_SUCCESS(Status))
{
@@ -1062,6 +1110,9 @@ CsrServerInitialization(IN ULONG ArgumentCount,
__FUNCTION__, Status);
return Status;
}
+#ifdef __REACTOS__
+ }
+#endif
/* Have us handle Hard Errors */
Status = NtSetDefaultHardErrorPort(CsrApiPort);
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2fef8be89206b7b0589d3…
commit 2fef8be89206b7b0589d3c05e5cc94587ceed9bf
Author: George Bișoc <george.bisoc(a)reactos.org>
AuthorDate: Sun Nov 6 17:47:30 2022 +0100
Commit: George Bișoc <george.bisoc(a)reactos.org>
CommitDate: Tue Nov 8 18:24:37 2022 +0100
[NTOS:SE] Dump security debug info in case no every right has been granted in SepAccessCheck
The "failed to grant access rights" message isn't enough to understand what kind of access rights haven't been granted and why. Dumping information of the captured security descriptor, the ACL and its ACEs with mask rights and token SIDs should be enough to understand the reason of the failure in question.
---
ntoskrnl/se/accesschk.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/ntoskrnl/se/accesschk.c b/ntoskrnl/se/accesschk.c
index 2a92a0ef247..0796dc8db78 100644
--- a/ntoskrnl/se/accesschk.c
+++ b/ntoskrnl/se/accesschk.c
@@ -479,23 +479,20 @@ SepAccessCheck(
_Out_ PNTSTATUS AccessStatusList)
{
ACCESS_MASK RemainingAccess;
- PACCESS_CHECK_RIGHTS AccessCheckRights;
- PACCESS_TOKEN Token;
ULONG ResultListLength;
ULONG ResultListIndex;
PACL Dacl;
BOOLEAN Present;
BOOLEAN Defaulted;
NTSTATUS Status;
+ PACCESS_TOKEN Token = NULL;
+ PACCESS_CHECK_RIGHTS AccessCheckRights = NULL;
PAGED_CODE();
/* A security descriptor must be expected for access checks */
ASSERT(SecurityDescriptor);
- /* Assume no access check rights first */
- AccessCheckRights = NULL;
-
/* Check for no access desired */
if (!DesiredAccess)
{
@@ -767,6 +764,16 @@ ReturnCommonStatus:
AccessStatusList[ResultListIndex] = Status;
}
+#if DBG
+ /* Dump security debug info on access denied case */
+ if (Status == STATUS_ACCESS_DENIED)
+ {
+ SepDumpSdDebugInfo(SecurityDescriptor);
+ SepDumpTokenDebugInfo(Token);
+ SepDumpAccessRightsStats(AccessCheckRights);
+ }
+#endif
+
/* Free the allocated access check rights */
SepFreeAccessCheckRights(AccessCheckRights);
AccessCheckRights = NULL;