zink: protect against invalid scissored renderpass clears
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 6 Jan 2023 19:36:45 +0000 (14:36 -0500)
committerEric Engestrom <eric@engestrom.ch>
Wed, 11 Jan 2023 17:44:22 +0000 (17:44 +0000)
if the clear region is oob, this is illegal and may crash some drivers

fixes (lavapipe):
dEQP-EGL.functional.swap_buffers_with_damage.resize_before_swap.buffer_age_clear_render
dEQP-EGL.functional.swap_buffers_with_damage.resize_before_swap.buffer_age_render_clear

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20584>
(cherry picked from commit 6f02fe8842f9fc6e0cecad533451a6402539c027)

.pick_status.json
src/gallium/drivers/zink/zink_clear.c

index 53bb5f5..b4cfd22 100644 (file)
         "description": "zink: protect against invalid scissored renderpass clears",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
index eaebcb3..cfb66df 100644 (file)
@@ -88,6 +88,9 @@ clear_in_rp(struct pipe_context *pctx,
 
    VkClearRect cr = {0};
    if (scissor_state) {
+      /* invalid clear */
+      if (scissor_state->minx > ctx->fb_state.width || scissor_state->miny > ctx->fb_state.height)
+         return;
       cr.rect.offset.x = scissor_state->minx;
       cr.rect.offset.y = scissor_state->miny;
       cr.rect.extent.width = MIN2(fb->width, scissor_state->maxx - scissor_state->minx);