Skip to content

Commit

Permalink
[L0] Fix use after free with Module build strings
Browse files Browse the repository at this point in the history
- Address Sanitizer HASAN fails with temporary strings even after last
  use after free patch. This change resolves all use after free of these
strings satifsying the address sanitzer checks with HASAN.

Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
  • Loading branch information
nrspruit committed Dec 17, 2024
1 parent c36a0b6 commit 3973136
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions source/adapters/level_zero/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,9 @@ ur_result_t urProgramLinkExp(
// Build flags may be different for different devices, so handle them
// here. Clear values of the previous device first.
BuildFlagPtrs.clear();
std::vector<std::string> TemporaryOptionsStrings;
for (uint32_t I = 0; I < count; I++) {
TemporaryOptionsStrings.push_back(
phPrograms[I]->getBuildOptions(ZeDevice));
BuildFlagPtrs.push_back(TemporaryOptionsStrings.back().c_str());
BuildFlagPtrs.push_back(
phPrograms[I]->getBuildOptions(ZeDevice).c_str());
}
ZeExtModuleDesc.pBuildFlags = BuildFlagPtrs.data();
if (count == 1)
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ struct ur_program_handle_t_ : _ur_object {
DeviceDataMap[ZeDevice].BuildFlags += Options;
}

std::string getBuildOptions(ze_device_handle_t ZeDevice) {
std::string &getBuildOptions(ze_device_handle_t ZeDevice) {
return DeviceDataMap[ZeDevice].BuildFlags;
}

Expand Down

0 comments on commit 3973136

Please sign in to comment.