From 7712c7e743f6a855ef1290362fe6df2d27ee12cb Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Tue, 21 Apr 2020 19:51:58 -0500 Subject: [PATCH] Correct IPC fragment validation. IPC create must only be used on whole ROCr allocations. Fragments were allowing handle creation with offsets. Change-Id: I1faa96d36bc7a6199bdc2e3ff1b8871d1a36a2fa --- runtime/hsa-runtime/core/runtime/runtime.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/hsa-runtime/core/runtime/runtime.cpp b/runtime/hsa-runtime/core/runtime/runtime.cpp index 612e5ad876..dd6a15ca28 100644 --- a/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -889,6 +889,8 @@ hsa_status_t Runtime::IPCCreate(void* ptr, size_t len, hsa_amd_ipc_memory_t* han info.size = sizeof(info); if (PtrInfo(ptr, &info, nullptr, nullptr, nullptr, &block) != HSA_STATUS_SUCCESS) return HSA_STATUS_ERROR_INVALID_ARGUMENT; + if ((info.agentBaseAddress != ptr) || (info.sizeInBytes != len)) + return HSA_STATUS_ERROR_INVALID_ARGUMENT; if ((block.base != ptr) || (block.length != len)) { if (!IsMultipleOf(block.base, 2 * 1024 * 1024)) { assert(false && "Fragment's block not aligned to 2MB!");