[NTOSKRNL]

Make NtDuplicateToken fail if the caller tries to create a new impersonation token with a raised impersonation level. This fixes a winetest.

svn path=/trunk/; revision=47456
This commit is contained in:
Eric Kohl 2010-05-30 19:46:02 +00:00
parent 2e0bbab8ca
commit dfc4dcb9b5

View file

@ -1844,8 +1844,32 @@ NtDuplicateToken(IN HANDLE ExistingTokenHandle,
PreviousMode, PreviousMode,
(PVOID*)&Token, (PVOID*)&Token,
NULL); NULL);
if (NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SepReleaseSecurityQualityOfService(CapturedSecurityQualityOfService,
PreviousMode,
FALSE);
return Status;
}
/*
* Fail, if the original token is an impersonation token and the caller
* tries to raise the impersonation level of the new token above the
* impersonation level of the original token.
*/
if (Token->TokenType == TokenImpersonation)
{
if (QoSPresent &&
CapturedSecurityQualityOfService->ImpersonationLevel >Token->ImpersonationLevel)
{
ObDereferenceObject(Token);
SepReleaseSecurityQualityOfService(CapturedSecurityQualityOfService,
PreviousMode,
FALSE);
return STATUS_BAD_IMPERSONATION_LEVEL;
}
}
Status = SepDuplicateToken(Token, Status = SepDuplicateToken(Token,
ObjectAttributes, ObjectAttributes,
EffectiveOnly, EffectiveOnly,
@ -1864,7 +1888,6 @@ NtDuplicateToken(IN HANDLE ExistingTokenHandle,
0, 0,
NULL, NULL,
&hToken); &hToken);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
_SEH2_TRY _SEH2_TRY
@ -1878,7 +1901,6 @@ NtDuplicateToken(IN HANDLE ExistingTokenHandle,
_SEH2_END; _SEH2_END;
} }
} }
}
/* Free the captured structure */ /* Free the captured structure */
SepReleaseSecurityQualityOfService(CapturedSecurityQualityOfService, SepReleaseSecurityQualityOfService(CapturedSecurityQualityOfService,