drm/lease: Make sure implicit planes are leased
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 28 Feb 2019 14:49:08 +0000 (15:49 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 24 Apr 2019 09:30:32 +0000 (11:30 +0200)
If userspace doesn't enable universal planes, then we automatically
add the primary and cursor planes. But for universal userspace there's
no such check (and maybe we only want to give the lessee one plane,
maybe not even the primary one), hence we need to check for the
implied plane.

v2: don't forget setcrtc ioctl.

v3: Still allow disabling of the crtc in SETCRTC.

Cc: stable@vger.kernel.org
Cc: Keith Packard <keithp@keithp.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190228144910.26488-6-daniel.vetter@ffwll.ch
drivers/gpu/drm/drm_crtc.c
drivers/gpu/drm/drm_plane.c

index 7dabbaf033a16055671ccfdb9d164936a8b9a4da..790ba59419540d0072c57e75658a087b1ba21c23 100644 (file)
@@ -559,6 +559,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
 
        plane = crtc->primary;
 
+       /* allow disabling with the primary plane leased */
+       if (crtc_req->mode_valid && !drm_lease_held(file_priv, plane->base.id))
+               return -EACCES;
+
        mutex_lock(&crtc->dev->mode_config.mutex);
        DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx,
                                   DRM_MODESET_ACQUIRE_INTERRUPTIBLE, ret);
index 4cfb56893b7f2e50deed2334ec904389a2c33f43..d6ad60ab0d389a3f83d073ffaca2908d3af48c24 100644 (file)
@@ -960,6 +960,11 @@ retry:
                if (ret)
                        goto out;
 
+               if (!drm_lease_held(file_priv, crtc->cursor->base.id)) {
+                       ret = -EACCES;
+                       goto out;
+               }
+
                ret = drm_mode_cursor_universal(crtc, req, file_priv, &ctx);
                goto out;
        }
@@ -1062,6 +1067,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 
        plane = crtc->primary;
 
+       if (!drm_lease_held(file_priv, plane->base.id))
+               return -EACCES;
+
        if (crtc->funcs->page_flip_target) {
                u32 current_vblank;
                int r;