Skip to content

bound icd debug list index by capacity in rollback and destroy#1969

Merged
charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
aizu-m:debug-list-index-bounds
Jul 13, 2026
Merged

bound icd debug list index by capacity in rollback and destroy#1969
charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
aizu-m:debug-list-index-bounds

Conversation

@aizu-m

@aizu-m aizu-m commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

ASAN, on an instance with VK_EXT_debug_utils and an allocator that refuses the per-ICD list growth:

ERROR: AddressSanitizer: heap-buffer-overflow READ of size 8
    #0 terminator_CreateDebugUtilsMessengerEXT debug_utils.c:243

Each ICD keeps its own debug_utils_messenger_list, grown one ICD at a time inside the create loop. Tracing the read back: the 33rd messenger create reserves used-object slot 32, so every list has to grow. If the reservation succeeds but a later per-ICD resize is refused, that ICD's list stays at 32 entries while next_index is already 32. The error rollback then indexed list[next_index] with only a NULL check, ran off the end of the smaller allocation, and could hand a garbage handle to the driver's Destroy.

The instance-list access just below already guards this with capacity > next_index * sizeof, and wsi_unwrap_icd_surface / cleanup_surface_creation guard the surface list the same way. The debug lists were the ones without it.

Added the bound at both create rollbacks and at the two destroy terminators, which index these lists the same way. The repro in loader_alloc_callback_tests.cpp forces the per-ICD resize to fail; it trips ASAN before the change and passes after.

The per-ICD debug messenger and report lists are grown one ICD at a time in the create loop, so a create that fails after the used-object slot is reserved but before a given ICD's list is grown left the error rollback indexing list[next_index] past the end of the smaller allocation. Add the capacity > index * sizeof bound that the instance-list and surface-list accesses already use, in both create rollbacks and both destroy terminators.
@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 38312.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3631 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3631 passed.

@charles-lunarg charles-lunarg merged commit 5133fcc into KhronosGroup:main Jul 13, 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