mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:05:54 +01:00
[PR #594] vulkan_backend: clear bindless_upload_semaphore_ in ~VulkanQueue (VK-QUEUE-BINDLESS-SEMAPHORE-UAF) #635
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#635
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/594
Author: @tahffo68hk-hash
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:fix/vk-queue-bindless-semaphore-uaf📝 Commits (1)
0c436aevulkan_backend: clear bindless_upload_semaphore_ in ~VulkanQueue (VK-QUEUE-BINDLESS-SEMAPHORE-UAF)📊 Changes
3 files changed (+176 additions, -2 deletions)
View changed files
📝
runtime/CMakeLists.txt(+15 -0)📝
runtime/src/vulkan_backend.h(+3 -2)➕
runtime/test/vk_queue_bindless_uaf_test.cpp(+158 -0)📄 Description
Summary
When a
VulkanQueuesubmits a command buffer carrying a new bindless descriptor table generation (context_.note_bindless_upload()),VulkanQueue::execute()publishes its own timeline semaphoreprogress_intocontext_.bindless_upload_semaphore_(understorage_mutex_) so other queues wait on it before binding the new generation.In
~VulkanQueue()(runtime/src/vulkan_backend.h), aftervkQueueWaitIdle(queue_)completes and beforevkDestroySemaphore(device, progress_, nullptr)destroysprogress_,~VulkanQueue()clearedcontext_.storage_init_semaphore_when it matchedprogress_, but did not clearcontext_.bindless_upload_semaphore_. Any other queue executing afterwards saw a non-nullbindless_upload_semaphore_with a newerbindless_upload_version_and passed the destroyedVkSemaphorehandle tovkQueueSubmit()inpWaitSemaphores(use-after-free /VUID-VkSubmitInfo-pWaitSemaphores-parameter).Fix
context_.bindless_upload_semaphore_ = VK_NULL_HANDLEalongsidecontext_.storage_init_semaphore_undercontext_.storage_mutex_in~VulkanQueue()(runtime/src/vulkan_backend.h).runtime/test/vk_queue_bindless_uaf_test.cpp(registered asvk_queue_bindless_uafinruntime/CMakeLists.txt) that:context.note_bindless_upload().VkSemaphorehandles viavkDestroySemaphore).vkQueueSubmit()and that the GPU copy readback matches expected bytes.Verification (Real Dual-GPU Hardware)
FAIL runtime/test/vk_queue_bindless_uaf_test.cpp:150: driver::dangling_wait_hits.load() == 0vk_queue_bindless_uaf_test: PASS (0 dangling waits, GPU readback verified)vk_queue_bindless_uaf_test: PASS (0 dangling waits, GPU readback verified)Coordination
VK-QUEUE-BINDLESS-SEMAPHORE-UAF(no overlapping open PRs or claims).中文翻译
摘要
当某个
VulkanQueue提交携带新一代 bindless 描述符表上传的命令缓冲(调用context_.note_bindless_upload())时,VulkanQueue::execute()会将该队列的 timeline semaphoreprogress_发布到context_.bindless_upload_semaphore_,供其他队列在后续提交时等待。在
~VulkanQueue()(runtime/src/vulkan_backend.h)等待队列空闲并销毁progress_之前,代码只清理了匹配的context_.storage_init_semaphore_,遗漏了context_.bindless_upload_semaphore_。此后其他队列执行提交时会把已销毁的VkSemaphore句柄传入vkQueueSubmit()的pWaitSemaphores,构成跨队列悬空句柄使用(use-after-free /VUID-VkSubmitInfo-pWaitSemaphores-parameter)。修复
~VulkanQueue()的storage_mutex_临界区内同步清理匹配的context_.bindless_upload_semaphore_ = VK_NULL_HANDLE。runtime/test/vk_queue_bindless_uaf_test.cpp(CMake 注册名vk_queue_bindless_uaf):Queue A 发布 bindless 上传并销毁后,Queue B 执行真实 GPU 拷贝并主机读回,验证vkQueueSubmit不再传入已销毁的 semaphore 且读回数据正确。真实双卡 GPU 验证
dangling_wait_hits != 0失败。PASS (0 dangling waits, GPU readback verified)。PASS (0 dangling waits, GPU readback verified)。协同
VK-QUEUE-BINDLESS-SEMAPHORE-UAF。🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.