Skip to content

[Coverity][UR][L0] Potential use after free #18514

Open
@AlexeySachkov

Description

@AlexeySachkov

See the issue at https://scan.coverity.com/projects/intel-llvm?tab=overview

CID `489992:

std::vector<ur_program_handle_t_::SpecConstantShim> SpecConstShims;
SpecConstShims.reserve(count);
for (uint32_t I = 0; I < count; I++) {
ur_program_handle_t Program = phPrograms[I];
CodeSizes[I] = Program->getCodeSize();
CodeBufs[I] = Program->getCode();
SpecConstShims.emplace_back(Program);
SpecConstPtrs[I] = SpecConstShims[I].ze();
}
ZeExtModuleDesc.count = count;
ZeExtModuleDesc.inputSizes = CodeSizes.data();
ZeExtModuleDesc.pInputModules = CodeBufs.data();
ZeExtModuleDesc.pConstants = SpecConstPtrs.data();

Spec constants information put into module descriptor points to heap-allocated data within stack-allocated vector. I'm not familiar enough with the L0 spec to know what is the expected lifetime of spec constant info within the descriptor, but it looks suspicious.

If that pointer is expected to be valid after zeModuleCreate then we definitely have a bug, because the memory will be de-allocated once we leave urProgramLinkExp.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions