#5 Backport dri2 x11 platform crash fix
Merged 4 months ago by lyude. Opened 4 months ago by jadahl.
rpms/ jadahl/mesa dri2-x11-crash-fix  into  f30

Backport dri2 x11 platform crash fix
Jonas Ådahl • 4 months ago  

@@ -0,0 +1,52 @@ 

+ From 47e16d01da1754a11c258460c82af6c797c4e546 Mon Sep 17 00:00:00 2001

+ From: Kenneth Graunke <kenneth@whitecape.org>

+ Date: Thu, 6 Jun 2019 22:17:06 -0700

+ Subject: [PATCH] egl/x11: calloc dri2_surf so it's properly zeroed

+ MIME-Version: 1.0

+ Content-Type: text/plain; charset=UTF-8

+ Content-Transfer-Encoding: 8bit

+ 

+ Commit 2282ec0a refactored drawable creation across various platforms

+ into a new dri2_create_drawable helper function.

+ 

+ The GBM code in platform_drm.c code passed in dri2_surf->gbm_surf as the

+ loaderPrivate, while most other backends passed in dri2_surf directly.

+ 

+ To try and handle this, the patch checked if dri2_surf->gbm_surf was

+ non-NULL, and if so, presumed that the caller is the DRM platform and

+ we should use the dri2_surf->gbm_surf pointer.

+ 

+ This worked for most platforms, which calloc their dri2_surf structure,

+ zeroing the data.  Unfortunately, platform_x11.c used malloc, leaving

+ most of the dri2_surf as garbage.  In particular, dri2_surf->gbm_surf

+ was often non-NULL, causing dri2_create_drawable to try and use it,

+ passing a garbage pointer to the createNewDrawable hook, usually leading

+ to a SIGBUS or SIGSEGV when trying to dereference that bad pointer.

+ 

+ Since most callers calloc the data, make platform_x11.c follow suit.

+ 

+ Fixes crashes with i915_dri.so when running dEQP-GLES2.

+ 

+ Reviewed-by: Mathias Fröhlich <Mathias.Froehlich@web.de>

+ Reviewed-by: Tapani Pälli <tapani.palli@intel.com>

+ (cherry picked from commit 4e3297f7d4d87618bf896ac503e1f036a7b6befb)

+ ---

+  src/egl/drivers/dri2/platform_x11.c | 2 +-

+  1 file changed, 1 insertion(+), 1 deletion(-)

+ 

+ diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c

+ index aa1e6cfc498..135d06f0187 100644

+ --- a/src/egl/drivers/dri2/platform_x11.c

+ +++ b/src/egl/drivers/dri2/platform_x11.c

+ @@ -261,7 +261,7 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,

+  

+     (void) drv;

+  

+ -   dri2_surf = malloc(sizeof *dri2_surf);

+ +   dri2_surf = calloc(1, sizeof *dri2_surf);

+     if (!dri2_surf) {

+        _eglError(EGL_BAD_ALLOC, "dri2_create_surface");

+        return NULL;

+ -- 

+ 2.21.0

+ 

file modified
+7 -1

@@ -49,7 +49,7 @@ 

  Summary:        Mesa graphics libraries

  %global ver 19.0.7

  Version:        %{lua:ver = string.gsub(rpm.expand("%{ver}"), "-", "~"); print(ver)}

- Release:        1%{?dist}

+ Release:        2%{?dist}

  License:        MIT

  URL:            http://www.mesa3d.org

  

@@ -65,6 +65,9 @@ 

  # https://bugzilla.redhat.com/show_bug.cgi?id=1560481

  Patch7:         0001-gallium-Disable-rgb10-configs-by-default.patch

  

+ # Backport dri2 x11 platform crash fix

+ Patch8:         0001-egl-x11-calloc-dri2_surf-so-it-s-properly-zeroed.patch

+ 

  BuildRequires:  meson >= 0.45

  BuildRequires:  gcc

  BuildRequires:  gcc-c++

@@ -617,6 +620,9 @@ 

  %endif

  

  %changelog

+ * Wed Jun 26 2019 Jonas Ådahl <jadahl@redhat.com> - 19.0.7-2

+ - Backport dri2 x11 platform crash fix

+ 

  * Tue Jun 25 2019 Pete Walter <pwalter@fedoraproject.org> - 19.0.7-1

  - Update to 19.0.7

  

Without it, mutter tests crashes in mesa.

Figured I might as well approve this since I got a notification for this in my email. Patch looks fine to me

Pull-Request has been merged by lyude

4 months ago