fix: default initialize allocated memory when memory is overwritten

Related-To: NEO-5093

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2025-03-11 12:16:50 +00:00
committed by Compute-Runtime-Automation
parent 8ec5434460
commit a86105814d
7 changed files with 13 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2024 Intel Corporation
* Copyright (C) 2020-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -93,7 +93,7 @@ const SipKernel &BuiltIns::getSipKernel(Device &device, OsContext *context) {
UNRECOVERABLE_IF(bindlessSip.getBinary().size() == 0);
auto binarySize = alignUp(bindlessSip.getBinary().size(), sizeof(uint32_t)) / sizeof(uint32_t);
auto binary = std::make_unique<uint32_t[]>(binarySize);
auto binary = std::make_unique_for_overwrite<uint32_t[]>(binarySize);
memcpy_s(binary.get(), binarySize * sizeof(uint32_t), bindlessSip.getBinary().data(), bindlessSip.getBinary().size());
const auto allocType = AllocationType::kernelIsaInternal;

View File

@@ -147,7 +147,7 @@ bool RegistryReader::getSettingStringCommon(const char *settingName, std::string
&regSize);
if (ERROR_SUCCESS == success) {
if (regType == REG_SZ || regType == REG_MULTI_SZ) {
auto regData = std::make_unique<char[]>(regSize);
auto regData = std::make_unique_for_overwrite<char[]>(regSize);
success = SysCalls::regQueryValueExA(key,
settingName,
NULL,
@@ -160,7 +160,7 @@ bool RegistryReader::getSettingStringCommon(const char *settingName, std::string
}
} else if (regType == REG_BINARY) {
size_t charCount = regSize / sizeof(wchar_t);
auto regData = std::make_unique<wchar_t[]>(charCount);
auto regData = std::make_unique_for_overwrite<wchar_t[]>(charCount);
success = SysCalls::regQueryValueExA(key,
settingName,
NULL,

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
* Copyright (C) 2021-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -28,7 +28,7 @@ std::wstring queryAdapterDriverStorePath(const Gdi &gdi, D3DKMT_HANDLE adapter)
DEBUG_BREAK_IF(queryRegistryInfoSizeDesc.Status != D3DDDI_QUERYREGISTRY_STATUS_BUFFER_OVERFLOW);
const auto privateDataSizeNeeded = queryRegistryInfoSizeDesc.OutputValueSize + sizeof(D3DDDI_QUERYREGISTRY_INFO);
auto storage = std::make_unique<uint64_t[]>((privateDataSizeNeeded + sizeof(uint64_t) - 1) / sizeof(uint64_t));
auto storage = std::make_unique_for_overwrite<uint64_t[]>((privateDataSizeNeeded + sizeof(uint64_t) - 1) / sizeof(uint64_t));
D3DDDI_QUERYREGISTRY_INFO &queryRegistryInfoValueDesc = *reinterpret_cast<D3DDDI_QUERYREGISTRY_INFO *>(storage.get());
queryRegistryInfoValueDesc = {};
queryRegistryInfoValueDesc.QueryType = D3DDDI_QUERYREGISTRY_DRIVERSTOREPATH;

View File

@@ -118,7 +118,7 @@ void TagAllocator<TagType>::populateFreeTags() {
gfxAllocations.emplace_back(multiGraphicsAllocation);
auto nodesMemory = std::make_unique<NodeType[]>(tagCount);
auto nodesMemory = std::make_unique_for_overwrite<NodeType[]>(tagCount);
for (size_t i = 0; i < tagCount; ++i) {
auto tagOffset = i * tagSize;