Repository navigation
runtime: fail closed on non-ERROR_NO_TOKEN OpenThreadToken errors (D3D-236 follow-up) - #2032
Conversation
Flyander
left a comment
There was a problem hiding this comment.
The token handling change is a good correction: falling back to the process token only for ERROR_NO_TOKEN avoids inheriting privileges during anonymous impersonation, and the regression case exercises that path.
One contract mismatch remains in the granted path: CreateCommandQueue still returns S_OK for GLOBAL_REALTIME while leasing a queue created at standard Vulkan priority. The diagnostic log does not change the API result the game observes, so this is still a silent downgrade from the caller's perspective. D3D12 explicitly says a global-realtime request succeeds or fails as-is and is not silently downgraded. Please either create a queue with an actual corresponding backend priority or fail the request when the device cannot provide one; add a host comparison for the privileged case. Reference: https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_command_queue_priority
|
Tested c25a920 on an NVIDIA GeForce RTX 3050 Laptop GPU, driver 32.0.16.2101, Windows 11, native MSVC (VS 2022 Build Tools, Ninja, RelWithDebInfo): pass.
AI-assisted (Claude Code). |
…has_global_realtime_privilege Address @Flyander's post-merge review feedback on ItsNotRexed#1817 (D3D-236): - Only fall back from OpenThreadToken to OpenProcessToken when GetLastError() == ERROR_NO_TOKEN, failing closed on ERROR_CANT_OPEN_ANONYMOUS or any other thread-token error. - Log the standard-priority Vulkan queue approximation once on the granted global-realtime path. - Remove the +not_elevated skip predicate from compare_invalid_arguments and add a SecurityAnonymous impersonation regression test.
|
Thanks for the quick review @Flyander!
|
c25a920 to
a37d1e6
Compare
Summary
Addresses @Flyander's post-merge review feedback on #1817 (
D3D-236):runtime/shims/d3d12_vulkan_device.cpp:has_global_realtime_privilege(), fall back fromOpenThreadToken(GetCurrentThread(), TOKEN_QUERY, TRUE, &token)toOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)only whenGetLastError() == ERROR_NO_TOKEN(the thread is not impersonating). Any otherOpenThreadTokenerror (such asERROR_CANT_OPEN_ANONYMOUSunderSecurityAnonymousimpersonation) now returnsfalseimmediately so an impersonated caller cannot inherit the process token'sSeIncreaseBasePriorityPrivilege.ID3D12Device::CreateCommandQueue, log the standard-priority Vulkan queue approximation once vialog_once("CreateCommandQueue: global realtime priority runs on a standard-priority Vulkan queue, type", desc->Type)on the granted path (since Vulkan queue global priorities are fixed atvkCreateDevicetime beforeCreateCommandQueueis called).runtime/test/d3d12_vulkan_device_test.cpp:#1737's+not_elevatedskip predicate from"command queue: global realtime priority"incompare_invalid_argumentsnow thatoursandhostagree in both privileged and unprivileged sessions.SecurityAnonymousthread impersonation regression test (DuplicateTokenEx(..., SecurityAnonymous, TokenImpersonation, ...)+SetThreadToken+RevertToSelf) verifying thatOpenThreadTokenfails withERROR_CANT_OPEN_ANONYMOUS,has_global_realtime_privilege()fails closed (false), andCreateCommandQueuereturnsDXGI_ERROR_ACCESS_DENIEDeven when the process token hasSeIncreaseBasePriorityPrivilegeenabled.Verification
d3d12_vulkan_device_test.exewithLEONIDA_VK_VALIDATION=1on:621.24, Vulkan1.4.357, Resizable BAR)19.44.35230.0, Vulkan SDK1.4.363.0d3d12_vulkan_device_testexited0with0Vulkan validation errors.AI Disclosure
AI-assisted (Gemini). Every line of the diff and all test outputs were reviewed and verified locally with
LEONIDA_VK_VALIDATION=1.