nvc0: reset TFB bufctx when we no longer hold a reference to the buffers
authorIlia Mirkin <imirkin@alum.mit.edu>
Tue, 16 Feb 2016 06:02:52 +0000 (01:02 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Sun, 6 Mar 2016 15:14:52 +0000 (10:14 -0500)
This fixes some use-after-free situations in dEQP when an xfb state is
removed, and then a clear is triggered, which only does a partial
validation. It would attempt to read the no-longer-valid buffers,
resulting in crashes.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
src/gallium/drivers/nouveau/nvc0/nvc0_state.c

index 6b02ed5680af8b02542b2628421a62dd5fb10670..01fe7ce9bfc34303a798a1cc1e7f3120f5246072 100644 (file)
@@ -309,7 +309,6 @@ nvc0_tfb_validate(struct nvc0_context *nvc0)
 
    if (!(nvc0->dirty_3d & NVC0_NEW_3D_TFB_TARGETS))
       return;
-   nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_3D_TFB);
 
    for (b = 0; b < nvc0->num_tfbbufs; ++b) {
       struct nvc0_so_target *targ = nvc0_so_target(nvc0->tfbbuf[b]);
index 7ccce9ff6bf90b646153d2f107ef5bf0ff9062f8..f679578028f494ba70b1648afc2a8107b4131d07 100644 (file)
@@ -1184,8 +1184,10 @@ nvc0_set_transform_feedback_targets(struct pipe_context *pipe,
    }
    nvc0->num_tfbbufs = num_targets;
 
-   if (nvc0->tfbbuf_dirty)
+   if (nvc0->tfbbuf_dirty) {
+      nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_3D_TFB);
       nvc0->dirty_3d |= NVC0_NEW_3D_TFB_TARGETS;
+   }
 }
 
 static void