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 <eric@engestrom.ch> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3103> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3103>
This commit is contained in:

committed by
Eric Engestrom

parent
39e7492d33
commit
047162d99c
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user