Re: [Mesa-dev] [PATCH] egl: avoid eglCreatePlatform*Surface{EXT, } crash with invalid dpy

2017-08-09 Thread Tapani Pälli


Yeah, _eglLookupDisplay seems to return NULL indeed in this case;

Reviewed-by: Tapani Pälli 

On 08/08/2017 05:55 PM, Emil Velikov wrote:

From: Emil Velikov 

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.

An 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-sta...@lists.freedesktop.org
Cc: Tapani Pälli 
Cc: Chad Versace 
Signed-off-by: Emil Velikov 
---
  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 c5e3955c48c..8146009da4f 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;



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


Re: [Mesa-dev] [PATCH] egl: avoid eglCreatePlatform*Surface{EXT, } crash with invalid dpy

2017-08-09 Thread Eric Engestrom
On Tuesday, 2017-08-08 15:55:36 +0100, Emil Velikov wrote:
> From: Emil Velikov 
> 
> 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.
> 
> An 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-sta...@lists.freedesktop.org
> Cc: Tapani Pälli 
> Cc: Chad Versace 
> Signed-off-by: Emil Velikov 

Reviewed-by: Eric Engestrom 

> ---
>  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 c5e3955c48c..8146009da4f 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;
> -- 
> 2.14.0
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] egl: avoid eglCreatePlatform*Surface{EXT, } crash with invalid dpy

2017-08-08 Thread Emil Velikov
From: Emil Velikov 

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.

An 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-sta...@lists.freedesktop.org
Cc: Tapani Pälli 
Cc: Chad Versace 
Signed-off-by: Emil Velikov 
---
 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 c5e3955c48c..8146009da4f 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;
-- 
2.14.0

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