loader: clamp driver-reported device extension count to caller buffer - #2021
Merged
Merged
Conversation
terminator_EnumerateDeviceExtensionProperties trusted the count the driver wrote back as the bound for the has_vk_extension_property_array dedup scan over the caller's pProperties, so a driver reporting more than the buffer holds read past its end. Clamp written_count to the caller-supplied count after the driver call.
|
Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build. |
1 similar comment
|
Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build. |
charles-lunarg
approved these changes
Aug 27, 2026
|
CI Vulkan-Loader build queued with queue ID 93351. |
|
CI Vulkan-Loader build # 3728 running. |
|
CI Vulkan-Loader build # 3728 passed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ASan, calling vkEnumerateDeviceExtensionProperties with app-supplied storage against a driver that over-reports the number of extensions it wrote:
Found while going over the driver-count paths in loader.c. On the branch where the app passes its own pProperties, the caller's *pPropertyCount is handed to the driver as the buffer size, and the count the driver writes back (written_count) is then used as the element count for the has_vk_extension_property_array dedup scan over pProperties while merging in implicit-layer device extensions. written_count is never bounded back to the storage that was given, so a driver returning VK_SUCCESS with a larger count walks the scan off the end of the caller's buffer. The *pPropertyCount <= written_count check lower down only covers the memcpy append, and it runs after the read.
Clamp written_count to the caller-supplied count right after the driver call. A conformant driver returning VK_SUCCESS never writes more than the capacity it was handed, so this is a no-op for them.
The regression test drives a driver reporting 64 entries into a one-element buffer with an implicit layer present. It trips ASan before the change and passes after.