From: Alexander van der Grinten Date: Sun, 15 Dec 2019 10:25:37 +0000 (+0100) Subject: egl: Fix _eglPointerIsDereferencable w/o mincore() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=047162d99ced85115b8e9010f196b8d1ee405be2;p=mesa.git egl: Fix _eglPointerIsDereferencable w/o mincore() On platforms without mincore(), _eglPointerIsDereferencable() currently just checks whether p != NULL. This is not sufficient: In the Wayland platform code (i.e., in get_wl_surface_proxy()), _eglPointerIsDereferencable() is called on the version field of `struct wl_egl_window` which is 3 on current versions of Wayland. This causes a segfault when trying to dereference p. Fix this behavior by assuming that the first page of the process is never dereferencable. Reviewed-by: Eric Engestrom Tested-by: Marge Bot Part-of: --- diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 0d7270333ec..5760edc3d3c 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -161,10 +161,10 @@ _eglGetClientExtensionString(void) EGLBoolean _eglPointerIsDereferencable(void *p) { -#ifdef HAVE_MINCORE uintptr_t addr = (uintptr_t) p; - unsigned char valid = 0; const long page_size = getpagesize(); +#ifdef HAVE_MINCORE + unsigned char valid = 0; if (p == NULL) return EGL_FALSE; @@ -190,6 +190,7 @@ _eglPointerIsDereferencable(void *p) */ return EGL_TRUE; #else - return p != NULL; + // Without mincore(), we just assume that the first page is unmapped. + return addr >= page_size; #endif }