egl/wayland: add a NULL guard for the authenticate callback
authorSimon Ser <contact@emersion.fr>
Tue, 8 Dec 2020 18:17:37 +0000 (19:17 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 16 Dec 2020 13:48:48 +0000 (13:48 +0000)
On some platforms, the authenticate callback may be NULL, e.g. on
surfaceless. If a client tries to send a wl_drm.authenticate request
the handler tries to dereference the NULL pointer.

This can be reproduced with libva which unconditionally tries to use
wl_drm.authenticate even with render nodes [1]. Run a compositor with
a surfaceless context, then try to start e.g. mpv to trigger the
segfault.

[1]: https://github.com/intel/libva/pull/476

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7992>

src/egl/wayland/wayland-drm/wayland-drm.c

index b72d10f..29558ea 100644 (file)
@@ -180,7 +180,8 @@ drm_authenticate(struct wl_client *client,
 {
        struct wl_drm *drm = wl_resource_get_user_data(resource);
 
-       if (drm->callbacks.authenticate(drm->user_data, id) < 0)
+       if (!drm->callbacks.authenticate ||
+           drm->callbacks.authenticate(drm->user_data, id) < 0)
                wl_resource_post_error(resource,
                                       WL_DRM_ERROR_AUTHENTICATE_FAIL,
                                       "authenticate failed");