[Mesa-dev] [PATCH] glsl/images: bounds check image unit assignment

Ilia Mirkin imirkin at alum.mit.edu
Mon May 23 02:54:38 UTC 2016


On Sun, May 22, 2016 at 10:51 PM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> The CTS test:
> GL45-CTS.multi_bind.dispatch_bind_image_textures
> binds 192 image uniforms, we reject this later,
> but not until after we trash the contents of the
> struct gl_shader.
>
> Error now reads:
> Too many compute shader image uniforms (192 > 16)
> instead of
> Too many compute shader image uniforms (2745344416 > 16)
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/compiler/glsl/link_uniform_initializers.cpp | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/compiler/glsl/link_uniform_initializers.cpp b/src/compiler/glsl/link_uniform_initializers.cpp
> index c6346d5..48e9106 100644
> --- a/src/compiler/glsl/link_uniform_initializers.cpp
> +++ b/src/compiler/glsl/link_uniform_initializers.cpp
> @@ -145,6 +145,8 @@ set_opaque_binding(void *mem_ctx, gl_shader_program *prog,
>                      storage->opaque[sh].active) {
>                 for (unsigned i = 0; i < elements; i++) {
>                    const unsigned index = storage->opaque[sh].index + i;
> +                  if (index > MAX_IMAGE_UNIFORMS)
> +                     break;

Presumably you mean >= ? I might also recommend
ARRAY_SIZE(shader->ImageUnits), should that number get increased
separately from MAX_IMAGE_UNIFORMS. With those changes,

Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

>                    shader->ImageUnits[index] = storage->storage[i].i;
>                 }
>              }
> --
> 2.5.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list