Skip to content

clamp re-queried extension count in enumeration helpers#1943

Merged
charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
aizu-m:ext-enum-count-clamp
Jun 22, 2026
Merged

clamp re-queried extension count in enumeration helpers#1943
charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
aizu-m:ext-enum-count-clamp

Conversation

@aizu-m

@aizu-m aizu-m commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Tracing the device extension enumeration helpers for the misbehaving-driver case the recent *2KHR clamps covered, the same shape turns up in the plain enumeration paths that fill a loader-internal scratch array.

  1. each site queries the ICD for an extension count, sizes a scratch array to it, then calls the Enumerate*ExtensionProperties entrypoint again with that array.
  2. the loop over the scratch array is bounded by the count the second call writes back, not by the count the array was sized for.
  3. a driver that returns a larger count on the second call walks the loop past the allocation, reading out of bounds of the loader own buffer.

Clamped each loop to the snapshotted allocated count, same idea as the emulation terminators. Six sites: loader_add_instance_extensions, loader_add_device_extensions and check_physical_device_extensions_for_driver_properties_extension in loader.c, terminator_GetPhysicalDeviceToolPropertiesEXT in extension_manual.c, and the two PCI-bus checks in loader_linux.c.

@ci-tester-lunarg

Copy link
Copy Markdown

Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg

Copy link
Copy Markdown

Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 13074.

@charles-lunarg charles-lunarg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these two call patterns remind me why I appreciate the helper function I added to vulkaninfo. It takes a function pointer, arguments, and optional default value, then returns (in a std::vector) the contents. Granted its C++ but if the intervening logic wasn't as extensive I'd try to abstract the 2 call pattern here too.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3576 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3576 passed.

@charles-lunarg charles-lunarg merged commit ddaf5c7 into KhronosGroup:main Jun 22, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants