SWDEV-443018 - Restrict input range for value argument in hipPointerSetAttribute

Change-Id: I17b6448bf49aed49315a0b4c1426dcbe011735d9


[ROCm/clr commit: 5b72582474]
这个提交包含在:
Ioannis Assiouras 编写, Maneesh Gupta 于 2024-02-05 05:08:11 +00:00 提交
1 父节点 d6811208f4
当前提交 3316766258
1 个文件已更改
+5 -2
+5 -2
查看文件
@@ -3688,6 +3688,10 @@ hipError_t ihipPointerSetAttribute(const void* value, hipPointer_attribute attri
if (attribute != HIP_POINTER_ATTRIBUTE_SYNC_MEMOPS) {
return hipErrorInvalidValue;
}
const unsigned int syncMemops = *reinterpret_cast<const unsigned int*>(value);
if (syncMemops != 0 && syncMemops != 1) {
return hipErrorInvalidValue;
}
size_t offset = 0;
amd::Memory* memObj = getMemoryObject(ptr, offset);
@@ -3695,8 +3699,7 @@ hipError_t ihipPointerSetAttribute(const void* value, hipPointer_attribute attri
return hipErrorInvalidDevicePointer;
}
memObj->getUserData().sync_mem_ops_
= static_cast<const bool>(*(reinterpret_cast<const unsigned int*>(value)));
memObj->getUserData().sync_mem_ops_ = static_cast<const bool>(syncMemops);
return hipSuccess;
}