dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: DRI Development <dri-devel@lists.freedesktop.org>
Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	stable@vger.kernel.org, Keith Packard <keithp@keithp.com>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: [PATCH 5/7] drm/lease: Make sure implicit planes are leased
Date: Thu, 28 Feb 2019 18:00:32 +0100	[thread overview]
Message-ID: <20190228170034.27660-6-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <20190228170034.27660-1-daniel.vetter@ffwll.ch>

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>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_crtc.c  | 4 ++++
 drivers/gpu/drm/drm_plane.c | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 7dabbaf033a1..790ba5941954 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -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);
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 4cfb56893b7f..d6ad60ab0d38 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -960,6 +960,11 @@ static int drm_mode_cursor_common(struct drm_device *dev,
 		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;
-- 
2.14.4

  parent reply	other threads:[~2019-02-28 17:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28 17:00 [PATCH 0/7] some cleanups and uapi clarification for leases Daniel Vetter
2019-02-28 17:00 ` [PATCH 1/7] drm/leases: Drop object_id validation for negative ids Daniel Vetter
2019-02-28 17:00 ` [PATCH 2/7] drm/lease: Drop recursive leads checks Daniel Vetter
2019-02-28 17:00 ` [PATCH 3/7] drm/leases: Don't init to 0 in drm_master_create Daniel Vetter
2019-03-01 11:30   ` Mika Kuoppala
2019-02-28 17:00 ` [PATCH 4/7] drm/lease: Check for lessor outside of locks Daniel Vetter
2019-02-28 17:00 ` Daniel Vetter [this message]
2019-02-28 17:00 ` [PATCH 6/7] drm/atomic: Wire file_priv through for property changes Daniel Vetter
2019-02-28 17:00 ` [PATCH 7/7] drm/atomic: -EACCESS for lease-denied crtc lookup Daniel Vetter
  -- strict thread matches above, loose matches on Subject: below --
2019-02-28 14:49 [PATCH 0/7] some cleanups and uapi clarification for leases Daniel Vetter
2019-02-28 14:49 ` [PATCH 5/7] drm/lease: Make sure implicit planes are leased Daniel Vetter
2019-03-05 13:35   ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190228170034.27660-6-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=keithp@keithp.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).