Skip to content

fix oob operand read on short coopMatPerElementNV arg list - #4395

Open
saddamr3e wants to merge 1 commit into
KhronosGroup:mainfrom
saddamr3e:coopmat-perelement-argcount
Open

fix oob operand read on short coopMatPerElementNV arg list#4395
saddamr3e wants to merge 1 commit into
KhronosGroup:mainfrom
saddamr3e:coopmat-perelement-argcount

Conversation

@saddamr3e

Copy link
Copy Markdown
Contributor

ASan, coopMatPerElementNV() and coopMatPerElementNV(relu):

SEGV in spv::Builder::getContainedTypeId (SpvBuilder.cpp:1782)
  from TGlslangToSpvTraverser::visitAggregate (GlslangToSpv.cpp:4943), reading operands[0]

coopMatPerElementNV/EXT are declared with an empty prototype (void coopMatPerElementNV();), so overload resolution accepts any argument list. A call missing one of the required (result matrix, input matrix, per-element function) operands is not passed as an aggregate, so the whole validation body in handleCoopMat2FunctionCall (guarded by arguments->getAsAggregate()) is skipped and the malformed EOpCooperativeMatrixPerElementOpNV reaches codegen, where operands[0] is read as the result matrix: with no arguments the operand vector is empty, with one it holds the function id whose type lookup dereferences a null instruction.

Reject a per-element call that is not an aggregate of at least three arguments in the front end. Both builtins map to EOpCooperativeMatrixPerElementOpNV, so one check covers them, and only these two use the empty prototype. Added Test/spv.coopmat2_perelement_error.comp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant