Skip to content

Commit 4349868

Browse files
amaioranomibrunin
authored andcommitted
[Backport] CVE-2024-2885: Use after free in Dawn
Manual cherry-pick of patch originally reviewed on https://chromium-review.googlesource.com/c/external/github.com/microsoft/DirectXShaderCompiler/+/5383595: Fix HLMatrixLowerPass leaving call to dangling FunctionVal When lowering an hl.cast, when the operand was an undef matrix, the pass would insert a call to a mat2vec stub, but since the undef value is not an alloca, it never gets handled, and the call to the temporary stub remains. Since the stub FunctionVal gets deleted, when the instruction is accessed in a future pass, it reads a dangling pointer. The fix is to handle undef similarly to how constant 0 is handled, and to return an undef vector from lowerHLCast. Bug: chromium:328958020 Change-Id: Id31e3aa326d9cb9f03ea97139f14dc5292cd6f7b Reviewed-on: https://chromium-review.googlesource.com/c/external/github.com/microsoft/DirectXShaderCompiler/+/5383595 Reviewed-by: Ben Clayton <[email protected]> Reviewed-by: David Neto <[email protected]> Reviewed-by: Kenneth Russell <[email protected]> Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/553291 Reviewed-by: Michal Klocek <[email protected]>
1 parent ca016bb commit 4349868

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

chromium/third_party/dawn/third_party/dxc/lib/HLSL/HLMatrixLowerPass.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,11 @@ Value* HLMatrixLowerPass::getLoweredByValOperand(Value *Val, IRBuilder<> &Builde
381381
if (isa<ConstantAggregateZero>(Val))
382382
return ConstantAggregateZero::get(LoweredTy);
383383

384+
// Lower undef mat as undef vec
385+
if (isa<UndefValue>(Val)) {
386+
return UndefValue::get(LoweredTy);
387+
}
388+
384389
// Return a mat-to-vec translation stub
385390
FunctionType *TranslationStubTy = FunctionType::get(LoweredTy, { Ty }, /* isVarArg */ false);
386391
Function *TranslationStub = m_matToVecStubs->get(TranslationStubTy);

0 commit comments

Comments
 (0)