Mesa (main): egl/wayland: Don't try to access modifiers u_vector as dynarray

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 23 16:40:17 UTC 2022


Module: Mesa
Branch: main
Commit: f50fe9b0b6b108caa3334e4ddde1871b52ce9a31
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f50fe9b0b6b108caa3334e4ddde1871b52ce9a31

Author: Sebastian Keller <skeller at gnome.org>
Date:   Wed Jun 22 02:42:15 2022 +0200

egl/wayland: Don't try to access modifiers u_vector as dynarray

The modifiers are u_vectors, but the code was trying to access them
as dynarrays. This resulted in a wrong number of modifiers, which then
later on would also lead to invalid reads used as modifiers.

In the case of the iris driver, a wrongly read number of modifiers > 0
would also trigger an error message.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6643
Fixes: b5848b2dac1 ("egl/wayland: use surface dma-buf feedback to allocate surface buffers")
Reviewed-by: Leandro Ribeiro <leandro.ribeiro at collabora.com>
Reviewed-by: Simon Ser <contact at emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17180>

---

 src/egl/drivers/dri2/platform_wayland.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index a40edbb4bbd..634c6062d4f 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -937,9 +937,8 @@ create_dri_image_from_dmabuf_feedback(struct dri2_egl_surface *dri2_surf,
       /* Ignore tranches that do not contain dri2_surf->format */
       if (!BITSET_TEST(tranche->formats.formats_bitmap, visual_idx))
          continue;
-      modifiers = util_dynarray_begin(&tranche->formats.modifiers[visual_idx]);
-      num_modifiers = util_dynarray_num_elements(&tranche->formats.modifiers[visual_idx],
-                                                 uint64_t);
+      modifiers = u_vector_tail(&tranche->formats.modifiers[visual_idx]);
+      num_modifiers = u_vector_length(&tranche->formats.modifiers[visual_idx]);
 
       /* For the purposes of this function, an INVALID modifier on
        * its own means the modifiers aren't supported. */



More information about the mesa-commit mailing list