Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory overlap on loader.c #988

Closed
rodrigoffzz opened this issue Jul 29, 2022 · 1 comment · Fixed by #989
Closed

Possible memory overlap on loader.c #988

rodrigoffzz opened this issue Jul 29, 2022 · 1 comment · Fixed by #989
Labels
bug Something isn't working

Comments

@rodrigoffzz
Copy link

Hi, I'm going through your code as part of the Main Inclusion Review [1] process for Ubuntu [2], and noticed something on the loader code that is present since the deprecated loader repo [3].
It was warned by a Coverity execution on the deprecated repo but as this part of the code remained the same, I think it worth reporting so you can check if it is really a problem or not.

The possible problem is a memory overlap in terminator_CreateInstance() @ loader.c in memcpy(&icd_app_info, icd_create_info.pApplicationInfo, sizeof(icd_app_info)); as icd_create_info.pApplicationInfo can be assigned with icd_app_info address, and is inside a for loop (assign the same address and then overlap memory in memcpy)
A suggestion would be to replace memcpy with memmove for a safer copy without the risk of overlaping

Vulkan-Loader/loader/loader.c

Lines 5322 to 5330 in 0bcddf3

if ((requested_version != 0) && (icd_version_nopatch == VK_API_VERSION_1_0)) {
if (icd_create_info.pApplicationInfo == NULL) {
memset(&icd_app_info, 0, sizeof(icd_app_info));
} else {
memcpy(&icd_app_info, icd_create_info.pApplicationInfo, sizeof(icd_app_info));
}
icd_app_info.apiVersion = icd_version;
icd_create_info.pApplicationInfo = &icd_app_info;
}

Do you think that this is something to be fixed?
Thanks!

[1] https://github.com/canonical/ubuntu-mir
[2] https://bugs.launchpad.net/ubuntu/+source/vulkan-tools/+bug/1946359
[3] https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers

@rodrigoffzz rodrigoffzz added the bug Something isn't working label Jul 29, 2022
@charles-lunarg
Copy link
Collaborator

Yep, this looks possible and is not a good thing to have happen. I created a PR for using memmove, assuming it passes CI I will merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants