mirror of
https://github.com/reactos/reactos.git
synced 2025-06-06 01:40:36 +00:00
[NTOS]
- Fix Job object session ID setting and comparison; fix a list initialization. - Correct some comments. - As Alex noticed it 7 years and 2 months ago, in revision 23197, the ProcessSessionInformation case in the NtSetInformationProcess API doesn't set a new session ID for the given process anymore (checked by myself too), because it is set once and for all at process creation time and is stored inside the Process->Session structure managed by MM. Therefore fake changing it: we just return success if the user-defined value is the same as the session ID of the process, and otherwise we fail. svn path=/trunk/; revision=60298
This commit is contained in:
parent
cfdd6612b1
commit
ba62280d9e
3 changed files with 36 additions and 9 deletions
|
@ -1576,7 +1576,7 @@ MiReleaseProcessReferenceToSessionDataPage(IN PMM_SESSION_SPACE SessionGlobal)
|
||||||
|
|
||||||
/* Get the session ID */
|
/* Get the session ID */
|
||||||
SessionId = SessionGlobal->SessionId;
|
SessionId = SessionGlobal->SessionId;
|
||||||
DPRINT1("Last process in sessino %lu going down!!!\n", SessionId);
|
DPRINT1("Last process in session %lu going down!!!\n", SessionId);
|
||||||
|
|
||||||
/* Free the session page tables */
|
/* Free the session page tables */
|
||||||
#ifndef _M_AMD64
|
#ifndef _M_AMD64
|
||||||
|
|
|
@ -169,8 +169,7 @@ NtAssignProcessToJobObject (
|
||||||
ExAcquireRundownProtection(&Process->RundownProtect);
|
ExAcquireRundownProtection(&Process->RundownProtect);
|
||||||
if(NT_SUCCESS(Status))
|
if(NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
// FIXME: This is broken
|
if(Process->Job == NULL && PsGetProcessSessionId(Process) == Job->SessionId)
|
||||||
if(Process->Job == NULL && PtrToUlong(Process->Session) == Job->SessionId)
|
|
||||||
{
|
{
|
||||||
/* Just store the pointer to the job object in the process, we'll
|
/* Just store the pointer to the job object in the process, we'll
|
||||||
assign it later. The reason we can't do this here is that locking
|
assign it later. The reason we can't do this here is that locking
|
||||||
|
@ -272,9 +271,12 @@ NtCreateJobObject (
|
||||||
the list before it even gets added! */
|
the list before it even gets added! */
|
||||||
Job->JobLinks.Flink = NULL;
|
Job->JobLinks.Flink = NULL;
|
||||||
|
|
||||||
/* setup the job object */
|
/* setup the job object - FIXME: More to do! */
|
||||||
|
InitializeListHead(&Job->JobSetLinks);
|
||||||
InitializeListHead(&Job->ProcessListHead);
|
InitializeListHead(&Job->ProcessListHead);
|
||||||
Job->SessionId = PtrToUlong(CurrentProcess->Session); /* inherit the session id from the caller, FIXME: broken */
|
|
||||||
|
/* inherit the session id from the caller */
|
||||||
|
Job->SessionId = PsGetProcessSessionId(CurrentProcess);
|
||||||
|
|
||||||
Status = ExInitializeResource(&Job->JobLock);
|
Status = ExInitializeResource(&Job->JobLock);
|
||||||
if(!NT_SUCCESS(Status))
|
if(!NT_SUCCESS(Status))
|
||||||
|
|
|
@ -1169,7 +1169,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* Getting VDM powers requires the SeTcbPrivilege */
|
/* Getting VDM powers requires the SeTcbPrivilege */
|
||||||
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
|
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
|
||||||
{
|
{
|
||||||
/* Bail out */
|
/* We don't hold the privilege, bail out */
|
||||||
Status = STATUS_PRIVILEGE_NOT_HELD;
|
Status = STATUS_PRIVILEGE_NOT_HELD;
|
||||||
DPRINT1("Need TCB privilege\n");
|
DPRINT1("Need TCB privilege\n");
|
||||||
break;
|
break;
|
||||||
|
@ -1213,7 +1213,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* Setting the error port requires the SeTcbPrivilege */
|
/* Setting the error port requires the SeTcbPrivilege */
|
||||||
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
|
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
|
||||||
{
|
{
|
||||||
/* Can't set the session ID, bail out. */
|
/* We don't hold the privilege, bail out */
|
||||||
Status = STATUS_PRIVILEGE_NOT_HELD;
|
Status = STATUS_PRIVILEGE_NOT_HELD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1332,11 +1332,13 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* Setting the session id requires the SeTcbPrivilege */
|
/* Setting the session id requires the SeTcbPrivilege */
|
||||||
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
|
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
|
||||||
{
|
{
|
||||||
/* Can't set the session ID, bail out. */
|
/* We don't hold the privilege, bail out */
|
||||||
Status = STATUS_PRIVILEGE_NOT_HELD;
|
Status = STATUS_PRIVILEGE_NOT_HELD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 // OLD AND DEPRECATED CODE!!!!
|
||||||
|
|
||||||
/* FIXME - update the session id for the process token */
|
/* FIXME - update the session id for the process token */
|
||||||
//Status = PsLockProcess(Process, FALSE);
|
//Status = PsLockProcess(Process, FALSE);
|
||||||
if (!NT_SUCCESS(Status)) break;
|
if (!NT_SUCCESS(Status)) break;
|
||||||
|
@ -1372,6 +1374,27 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
/* Unlock the process */
|
/* Unlock the process */
|
||||||
//PsUnlockProcess(Process);
|
//PsUnlockProcess(Process);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since we cannot change the session ID of the given
|
||||||
|
* process anymore because it is set once and for all
|
||||||
|
* at process creation time and because it is stored
|
||||||
|
* inside the Process->Session structure managed by MM,
|
||||||
|
* we fake changing it: we just return success if the
|
||||||
|
* user-defined value is the same as the session ID of
|
||||||
|
* the process, and otherwise we fail.
|
||||||
|
*/
|
||||||
|
if (SessionInfo.SessionId == PsGetProcessSessionId(Process))
|
||||||
|
{
|
||||||
|
Status = STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = STATUS_ACCESS_DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ProcessPriorityClass:
|
case ProcessPriorityClass:
|
||||||
|
@ -1612,6 +1635,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* Setting 'break on termination' requires the SeDebugPrivilege */
|
/* Setting 'break on termination' requires the SeDebugPrivilege */
|
||||||
if (!SeSinglePrivilegeCheck(SeDebugPrivilege, PreviousMode))
|
if (!SeSinglePrivilegeCheck(SeDebugPrivilege, PreviousMode))
|
||||||
{
|
{
|
||||||
|
/* We don't hold the privilege, bail out */
|
||||||
Status = STATUS_PRIVILEGE_NOT_HELD;
|
Status = STATUS_PRIVILEGE_NOT_HELD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1837,7 +1861,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
|
||||||
/* Only TCB can do this */
|
/* Only TCB can do this */
|
||||||
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
|
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
|
||||||
{
|
{
|
||||||
/* Fail */
|
/* We don't hold the privilege, bail out */
|
||||||
DPRINT1("Need TCB to set IOPL\n");
|
DPRINT1("Need TCB to set IOPL\n");
|
||||||
Status = STATUS_PRIVILEGE_NOT_HELD;
|
Status = STATUS_PRIVILEGE_NOT_HELD;
|
||||||
break;
|
break;
|
||||||
|
@ -2366,6 +2390,7 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
|
||||||
/* Setting 'break on termination' requires the SeDebugPrivilege */
|
/* Setting 'break on termination' requires the SeDebugPrivilege */
|
||||||
if (!SeSinglePrivilegeCheck(SeDebugPrivilege, PreviousMode))
|
if (!SeSinglePrivilegeCheck(SeDebugPrivilege, PreviousMode))
|
||||||
{
|
{
|
||||||
|
/* We don't hold the privilege, bail out */
|
||||||
Status = STATUS_PRIVILEGE_NOT_HELD;
|
Status = STATUS_PRIVILEGE_NOT_HELD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue