nv50,nvc0: avoid reading out of bounds when getting bogus so info
authorIlia Mirkin <imirkin@alum.mit.edu>
Wed, 19 Oct 2016 04:05:26 +0000 (00:05 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Thu, 20 Oct 2016 01:02:01 +0000 (21:02 -0400)
The state tracker tries to attach the info to the wrong shader. This is
easy enough to protect against.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Cc: 12.0 13.0 <mesa-stable@lists.freedesktop.org>
src/gallium/drivers/nouveau/nv50/nv50_program.c
src/gallium/drivers/nouveau/nvc0/nvc0_program.c

index 2b66877c6797905959764dd6891b682623d72cf6..ea5febdf3aef73a589ba4f56ba75533cae22d38d 100644 (file)
@@ -307,6 +307,9 @@ nv50_program_create_strmout_state(const struct nv50_ir_prog_info *info,
       const unsigned r = pso->output[i].register_index;
       b = pso->output[i].output_buffer;
 
+      if (r >= info->numOutputs)
+         continue;
+
       for (c = 0; c < pso->output[i].num_components; ++c)
          so->map[base[b] + p + c] = info->out[r].slot[s + c];
    }
index f52cbd298198196be40126e3b97b704adda6fe3d..a4a164f15f8af8cb4d4362822b1a4e0b38655677 100644 (file)
@@ -509,11 +509,14 @@ nvc0_program_create_tfb_state(const struct nv50_ir_prog_info *info,
    for (i = 0; i < pso->num_outputs; ++i) {
       unsigned s = pso->output[i].start_component;
       unsigned p = pso->output[i].dst_offset;
+      const unsigned r = pso->output[i].register_index;
       b = pso->output[i].output_buffer;
 
+      if (r >= info->numOutputs)
+         continue;
+
       for (c = 0; c < pso->output[i].num_components; ++c)
-         tfb->varying_index[b][p++] =
-            info->out[pso->output[i].register_index].slot[s + c];
+         tfb->varying_index[b][p++] = info->out[r].slot[s + c];
 
       tfb->varying_count[b] = MAX2(tfb->varying_count[b], p);
       tfb->stream[b] = pso->output[i].stream;