Mesa (17.2): egl: avoid eglCreatePlatform*Surface{EXT, } crash with invalid dpy

Emil Velikov evelikov at kemper.freedesktop.org
Sat Aug 12 16:12:26 UTC 2017


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

Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Tue Aug  8 15:55:36 2017 +0100

egl: avoid eglCreatePlatform*Surface{EXT,} crash with invalid dpy

If we have an invalid display fed into the functions, the display lookup
will return NULL. Thus as we attempt to get the platform type, we'll
deref. it leading to a crash.

Keep in mind that this will not happen if Mesa is built without X11 or
when the legacy eglCreate*Surface codepaths are used.

A similar check was added with earlier commit 5e97b8f5ce9 ("egl: Fix
crashes in eglCreate*Surface), although it was only applicable when the
surfaceless platform is built.

Cc: mesa-stable at lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
(cherry picked from commit 26fbb9eacddb1b809739cb12477bde13501d6d5a)
[Emil Velikov: resolve trivial conflicts]
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>

Conflicts:
	src/egl/main/eglapi.c

---

 src/egl/main/eglapi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 000368a46a..16ae741459 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -923,7 +923,7 @@ static void *
 _fixupNativeWindow(_EGLDisplay *disp, void *native_window)
 {
 #ifdef HAVE_X11_PLATFORM
-   if (disp->Platform == _EGL_PLATFORM_X11 && native_window != NULL) {
+   if (disp && disp->Platform == _EGL_PLATFORM_X11 && native_window != NULL) {
       /* The `native_window` parameter for the X11 platform differs between
        * eglCreateWindowSurface() and eglCreatePlatformPixmapSurfaceEXT(). In
        * eglCreateWindowSurface(), the type of `native_window` is an Xlib
@@ -985,7 +985,7 @@ _fixupNativePixmap(_EGLDisplay *disp, void *native_pixmap)
        * `Pixmap*`.  Convert `Pixmap*` to `Pixmap` because that's what
        * dri2_x11_create_pixmap_surface() expects.
        */
-   if (disp->Platform == _EGL_PLATFORM_X11 && native_pixmap != NULL)
+   if (disp && disp->Platform == _EGL_PLATFORM_X11 && native_pixmap != NULL)
       return (void *)(* (Pixmap*) native_pixmap);
 #endif
    return native_pixmap;




More information about the mesa-commit mailing list