null-terminate device name copies in linux device sort#1941
Open
aizu-m wants to merge 1 commit into
Open
Conversation
|
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. |
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, with a driver that fills all 256 bytes of deviceName and no terminator:
Was reading through the physical-device sort path. The loader copies the driver-reported deviceName into its own LinuxSortedDeviceInfo with strncpy bounded by the full VK_MAX_PHYSICAL_DEVICE_NAME_SIZE. strncpy leaves no terminator when the source occupies the whole field, so a driver that returns a 256-byte name produces an unterminated device_name. That field is then logged with %s, so the read runs off the end of the buffer, past the heap allocation for the last sorted entry.
We make our own copy here, so the termination has to be guaranteed on our side rather than trusted from the driver. The same copy is in linux_sort_physical_device_groups. Both now bound the copy to SIZE-1 and write the terminator, matching the strncpy plus explicit nul already used in loader_windows.c.