Skip to content

Commit 701e6f7

Browse files
committed
[libc][fix] Fix buffer overrun in initialization of GPU return value
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.
1 parent 65642c7 commit 701e6f7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libc/utils/gpu/loader/amdgpu/Loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ int load(int argc, char **argv, char **envp, void *image, size_t size,
397397
hsa_amd_memory_pool_allocate(coarsegrained_pool, sizeof(int),
398398
/*flags=*/0, &dev_ret))
399399
handle_error(err);
400-
hsa_amd_memory_fill(dev_ret, 0, sizeof(int));
400+
hsa_amd_memory_fill(dev_ret, 0, /*count=*/1);
401401

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

0 commit comments

Comments
 (0)