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

Buffer overflow at CudaAttentionOpTest::selfAttentionOpTest #57

Open
skmkt opened this issue May 14, 2024 · 1 comment
Open

Buffer overflow at CudaAttentionOpTest::selfAttentionOpTest #57

skmkt opened this issue May 14, 2024 · 1 comment

Comments

@skmkt
Copy link

skmkt commented May 14, 2024

Definition:
std::vector<void*> block_pointers(batch_size * 2 * maxBlocksPerSeq, nullptr);

...
auto kv_cache = device_->allocateBuffer(
{DataType::TYPE_UINT64, {(size_t)batch_size, maxBlocksPerSeq}, AllocationType::HOST}, {});

Copy size larger than dst size:
std::memcpy(kv_cache->data(), block_pointers.data(), block_pointers.size() * sizeof(void*));

block_pointers.size() * sizeof(void*) = batch_size * 2 * maxBlocksPerSeq * sizeof(void*)
kv_cache size() = batch_size * maxBlocksPerSeq * sizeof(unsigned long)

@netaddi
Copy link
Collaborator

netaddi commented May 16, 2024

Hi,
thank you for your comment on this bug. we are working on a fix now.
btw, how did you find this ?

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

No branches or pull requests

2 participants