Skip to content

Conversation

@tex3d
Copy link
Contributor

@tex3d tex3d commented Nov 1, 2025

A bug in HLOperationLower code that lowers the matrix subscript operation when the matrix is in a cbuffer could cause out-of-bounds alloca indexing.

The indexing creates an alloca to store a column-vector loaded from one cbuffer vector. This should have one element per row of the matrix, so it can then index along that dimension using the local array.

The bug was using the number of columns when sizing the alloca instead of the number of rows. This caused it to write to out-of-bounds index when the number of rows exceeded the number of columns (like for float3x2).

Fixes #7865.

A bug in HLOperationLower code that lowers the matrix subscript operation
when the matrix is in a cbuffer could cause out-of-bounds alloca indexing.

The indexing creates an alloca to store a column-vector loaded from one
cbuffer vector. This should have one element per row of the matrix, so it
can then index along that dimension using the local array.

The bug was using the number of columns when sizing the alloca instead of
the number of rows. This caused it to write to out-of-bounds index when the
number of rows exceeded the number of columns (like for float3x2).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

OOB write to alloca for col-major cbuffer matrix subscript when rows > cols

1 participant