Skip to content

Commit

Permalink
[libc][fix] Fix buffer overrun in initialization of GPU return value
Browse files Browse the repository at this point in the history
Summary:
The HSA API explicitly states that the size is a count of uint32_t's not
a byte count. This was erroneously being used as a simple memcpy,
causing some weird behaviour. Fix this by correctly passing `1` to
initialize a single integer to zero.
  • Loading branch information
jhuber6 committed Sep 2, 2023
1 parent 65642c7 commit 701e6f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libc/utils/gpu/loader/amdgpu/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ int load(int argc, char **argv, char **envp, void *image, size_t size,
hsa_amd_memory_pool_allocate(coarsegrained_pool, sizeof(int),
/*flags=*/0, &dev_ret))
handle_error(err);
hsa_amd_memory_fill(dev_ret, 0, sizeof(int));
hsa_amd_memory_fill(dev_ret, 0, /*count=*/1);

// Allocate finegrained memory for the RPC server and client to share.
uint32_t wavefront_size = 0;
Expand Down

0 comments on commit 701e6f7

Please sign in to comment.