fix: sanitize the array entries count returned from KMD

Related-To: NEO-11825
Signed-off-by: Maciej Bielski <maciej.bielski@intel.com>
This commit is contained in:
Maciej Bielski 2024-06-26 14:43:50 +00:00 committed by Compute-Runtime-Automation
parent 0b00c5deba
commit 3e11ced59b
1 changed files with 7 additions and 0 deletions

View File

@ -101,6 +101,13 @@ ze_result_t PlatformMonitoringTech::getGuid() {
return ZE_RESULT_ERROR_UNKNOWN;
}
auto maxEntriesCount = (sizeNeeded - offsetof(PmtSysman::PmtTelemetryDiscovery, telemetry)) / sizeof(PmtSysman::PmtTelemetryEntry);
if (telemetryDiscovery->count > maxEntriesCount) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Incorrect telemetry entries count.\n");
DEBUG_BREAK_IF(true);
return ZE_RESULT_ERROR_UNKNOWN;
}
for (uint32_t i = 0; i < telemetryDiscovery->count; i++) {
if (telemetryDiscovery->telemetry[i].index < PmtSysman::PmtMaxInterfaces) {
guidToIndexList[telemetryDiscovery->telemetry[i].index] = telemetryDiscovery->telemetry[i].guid;