Re: [Mesa-dev] [PATCH 1/2] mesa: add blob overrun check to program binary reads

2018-01-26 Thread Gert Wollny


On 26.01.2018 01:56, Timothy Arceri wrote:
> ---
>  src/mesa/main/program_binary.c | 14 ++
>  1 file changed, 14 insertions(+)
>
> diff --git a/src/mesa/main/program_binary.c b/src/mesa/main/program_binary.c
> index 2786487362..68a15ec258 100644
> --- a/src/mesa/main/program_binary.c
> +++ b/src/mesa/main/program_binary.c
> @@ -287,5 +287,19 @@ _mesa_program_binary(struct gl_context *ctx, struct 
> gl_shader_program *sh_prog,
>return;
> }
>  
> +   if (blob.current != blob.end || blob.overrun) {
> +  /* Something has gone wrong ignore the binary and set link status to
> +   * failure.
> +   */
> +  assert(!"Invalid program binary cache item!");
> +
> +  if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
> + fprintf(stderr, "Error reading program from program binary\n");
> +  }
> +  sh_prog->data->LinkStatus = linking_failure;
> +
> +  return;
> +   }
> +
> sh_prog->data->LinkStatus = linking_success;
>  }
This code is nearly a complete duplicate of what is done in
"st_deserialise_tgsi_program", only there messages are different and 
the LinkStatus is not set. Would it be possible to unify these two
pieces of code maybe in compiler/blob.h?

Best,
Gert 
 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] mesa: add blob overrun check to program binary reads

2018-01-25 Thread Timothy Arceri
---
 src/mesa/main/program_binary.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/src/mesa/main/program_binary.c b/src/mesa/main/program_binary.c
index 2786487362..68a15ec258 100644
--- a/src/mesa/main/program_binary.c
+++ b/src/mesa/main/program_binary.c
@@ -287,5 +287,19 @@ _mesa_program_binary(struct gl_context *ctx, struct 
gl_shader_program *sh_prog,
   return;
}
 
+   if (blob.current != blob.end || blob.overrun) {
+  /* Something has gone wrong ignore the binary and set link status to
+   * failure.
+   */
+  assert(!"Invalid program binary cache item!");
+
+  if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
+ fprintf(stderr, "Error reading program from program binary\n");
+  }
+  sh_prog->data->LinkStatus = linking_failure;
+
+  return;
+   }
+
sh_prog->data->LinkStatus = linking_success;
 }
-- 
2.14.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev