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

Out-of-bounds read in populateBufferWithCopy #417 #481

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ typedef void (*FillBufferProcPtr)(void *, vk::VkDeviceSize, const void *const);
void createTestBuffer(Context &context, const vk::DeviceInterface &deviceInterface, const VkDevice &device,
VkDeviceSize accessRange, VkBufferUsageFlags usage, SimpleAllocator &allocator,
Move<VkBuffer> &buffer, de::MovePtr<Allocation> &bufferAlloc, AccessRangesData &data,
FillBufferProcPtr fillBufferProc, const void *const blob)
FillBufferProcPtr fillBufferProc, const void *const blob, bool useAccessRange)
{
const VkBufferCreateInfo bufferParams = {
VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
Expand All @@ -127,9 +127,9 @@ void createTestBuffer(Context &context, const vk::DeviceInterface &deviceInterfa
VK_CHECK(deviceInterface.bindBufferMemory(device, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset()));
#ifdef CTS_USES_VULKANSC
if (context.getTestContext().getCommandLine().isSubProcess())
fillBufferProc(bufferAlloc->getHostPtr(), bufferMemoryReqs.size, blob);
fillBufferProc(bufferAlloc->getHostPtr(), useAccessRange ? accessRange : bufferMemoryReqs.size, blob);
#else
fillBufferProc(bufferAlloc->getHostPtr(), bufferMemoryReqs.size, blob);
fillBufferProc(bufferAlloc->getHostPtr(), useAccessRange ? accessRange : bufferMemoryReqs.size, blob);
DE_UNREF(context);
#endif // CTS_USES_VULKANCSC
flushMappedMemoryRange(deviceInterface, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), VK_WHOLE_SIZE);
Expand Down Expand Up @@ -1407,9 +1407,9 @@ AccessInstance::AccessInstance(Context &context, Move<VkDevice> device,
}

createTestBuffer(context, vk, *m_device, inBufferAccessRange, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, memAlloc,
m_inBuffer, m_inBufferAlloc, m_inBufferAccess, &populateBufferWithValues, &m_bufferFormat);
m_inBuffer, m_inBufferAlloc, m_inBufferAccess, &populateBufferWithValues, &m_bufferFormat, false);
createTestBuffer(context, vk, *m_device, outBufferAccessRange, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, memAlloc,
m_outBuffer, m_outBufferAlloc, m_outBufferAccess, &populateBufferWithFiller, nullptr);
m_outBuffer, m_outBufferAlloc, m_outBufferAccess, &populateBufferWithFiller, nullptr, false);

int32_t indices[] = {(m_accessOutOfBackingMemory && (m_bufferAccessType == BUFFER_ACCESS_TYPE_READ_FROM_STORAGE)) ?
static_cast<int32_t>(RobustAccessWithPointersTest::s_testArraySize) - 1 :
Expand All @@ -1420,7 +1420,7 @@ AccessInstance::AccessInstance(Context &context, Move<VkDevice> device,
0};
AccessRangesData indicesAccess;
createTestBuffer(context, vk, *m_device, 3 * sizeof(int32_t), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, memAlloc,
m_indicesBuffer, m_indicesBufferAlloc, indicesAccess, &populateBufferWithCopy, &indices);
m_indicesBuffer, m_indicesBufferAlloc, indicesAccess, &populateBufferWithCopy, &indices, true);

log << tcu::TestLog::Message << "input buffer - alloc size: " << m_inBufferAccess.allocSize
<< tcu::TestLog::EndMessage;
Expand Down Expand Up @@ -1520,7 +1520,7 @@ AccessInstance::AccessInstance(Context &context, Move<VkDevice> device,
};
const VkDeviceSize vertexBufferSize = static_cast<VkDeviceSize>(sizeof(vertices));
createTestBuffer(context, vk, *m_device, vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, memAlloc,
m_vertexBuffer, m_vertexBufferAlloc, vertexAccess, &populateBufferWithCopy, &vertices);
m_vertexBuffer, m_vertexBufferAlloc, vertexAccess, &populateBufferWithCopy, &vertices, true);

const GraphicsEnvironment::DrawConfig drawWithOneVertexBuffer = {
std::vector<VkBuffer>(1, *m_vertexBuffer), // std::vector<VkBuffer> vertexBuffers;
Expand Down