mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
fix: Fixed out-of-bounds write to usageInfos array with residency task count
Related-To: NEO-12952 Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
0fca7fb998
commit
76090f041d
@@ -176,6 +176,10 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation>, NEO::NonCopyableAn
|
||||
MOCKABLE_VIRTUAL bool isResident(uint32_t contextId) const { return GraphicsAllocation::objectNotResident != getResidencyTaskCount(contextId); }
|
||||
bool isAlwaysResident(uint32_t contextId) const { return GraphicsAllocation::objectAlwaysResident == getResidencyTaskCount(contextId); }
|
||||
void updateResidencyTaskCount(TaskCountType newTaskCount, uint32_t contextId) {
|
||||
if (contextId >= usageInfos.size()) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
return;
|
||||
}
|
||||
if (usageInfos[contextId].residencyTaskCount != GraphicsAllocation::objectAlwaysResident || newTaskCount == GraphicsAllocation::objectNotResident) {
|
||||
usageInfos[contextId].residencyTaskCount = newTaskCount;
|
||||
}
|
||||
|
||||
@@ -138,6 +138,12 @@ TEST(GraphicsAllocationTest, givenResidentGraphicsAllocationWhenCheckIfResidency
|
||||
EXPECT_TRUE(graphicsAllocation.isResidencyTaskCountBelow(currentResidencyTaskCount + 1u, 0u));
|
||||
}
|
||||
|
||||
TEST(GraphicsAllocationTest, givenResidentGraphicsAllocationWhenUpdatingResidencyTaskCountForUnusedContextIdThenDoEarlyReturn) {
|
||||
MockGraphicsAllocation graphicsAllocation;
|
||||
auto contextId = static_cast<uint32_t>(graphicsAllocation.usageInfos.size());
|
||||
graphicsAllocation.updateResidencyTaskCount(1u, contextId);
|
||||
}
|
||||
|
||||
TEST(GraphicsAllocationTest, givenAllocationTypeWhenCheckingCpuAccessRequiredThenReturnTrue) {
|
||||
for (uint32_t i = 0; i < static_cast<uint32_t>(AllocationType::count); i++) {
|
||||
auto allocType = static_cast<AllocationType>(i);
|
||||
|
||||
Reference in New Issue
Block a user