aco/isel: Fix out-of-bounds write in visit_load_input

Shaders may read out components past the attributes provided by the
application, so the read mask can indicate a larger component count than
were actually reserved in the array.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6728>
This commit is contained in:
Tony Wasserka 2020-09-14 19:39:43 +02:00 committed by Marge Bot
parent d38094bb33
commit 5f7810dcb2
1 changed files with 1 additions and 1 deletions

View File

@ -4568,7 +4568,7 @@ void visit_load_input(isel_context *ctx, nir_intrinsic_instr *instr)
/* skip unused channels at the start */
if (vtx_info->chan_byte_size && !post_shuffle) {
channel_start = ffs(mask) - 1;
for (unsigned i = 0; i < channel_start; i++)
for (unsigned i = 0; i < MIN2(channel_start, num_channels); i++)
channels[i] = Temp(0, s1);
} else if (vtx_info->chan_byte_size && post_shuffle && !(mask & 0x8)) {
num_channels = 3 - (ffs(mask) - 1);