dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel@daenzer.net>
To: dri-devel@lists.freedesktop.org
Cc: Dmitry Vyukov <dvyukov@google.com>
Subject: [PATCH 1/2] drm: Don't call drm_for_each_crtc with a non-KMS driver
Date: Wed, 30 Nov 2016 17:30:01 +0900	[thread overview]
Message-ID: <20161130083002.1520-1-michel@daenzer.net> (raw)
In-Reply-To: <CACT4Y+YrvoBKvnicUYAY=xKFMwyUCO2bRnACoX+GRzLgYT1X5A@mail.gmail.com>

From: Michel Dänzer <michel.daenzer@amd.com>

Fixes oops if userspace calls DRM_IOCTL_GET_CAP for
 DRM_CAP_PAGE_FLIP_TARGET on a non-KMS device node. (Normal userspace
doesn't do that, discovered by syzkaller)

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Fixes: f837297ad824 ("drm: Add DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags v2")
Cc: stable@vger.kernel.org
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 drivers/gpu/drm/drm_ioctl.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 0ad2c47..71c3473 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -254,10 +254,12 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 		req->value = dev->mode_config.async_page_flip;
 		break;
 	case DRM_CAP_PAGE_FLIP_TARGET:
-		req->value = 1;
-		drm_for_each_crtc(crtc, dev) {
-			if (!crtc->funcs->page_flip_target)
-				req->value = 0;
+		if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+			req->value = 1;
+			drm_for_each_crtc(crtc, dev) {
+				if (!crtc->funcs->page_flip_target)
+					req->value = 0;
+			}
 		}
 		break;
 	case DRM_CAP_CURSOR_WIDTH:
-- 
2.10.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2016-11-30  8:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09 11:56 drm: GPF in drm_getcap Dmitry Vyukov
2016-11-26 17:17 ` Dmitry Vyukov
2016-11-26 17:35   ` David Herrmann
2016-11-26 17:50     ` Dmitry Vyukov
2016-11-26 18:02       ` David Herrmann
2016-11-26 18:07         ` Dmitry Vyukov
2016-11-26 18:22           ` David Herrmann
2016-11-28  6:55             ` Daniel Vetter
2016-11-28  7:14               ` Michel Dänzer
2016-11-28  8:41                 ` Dmitry Vyukov
2016-11-30  8:30                   ` Michel Dänzer [this message]
2016-11-30  8:30                     ` [PATCH 2/2] drm: Return -ENOTSUPP when called for KMS cap with a non-KMS driver Michel Dänzer
2016-11-30  9:07                       ` Daniel Vetter
2016-11-30 17:21                         ` Alex Deucher
2016-12-01  7:35                         ` Michel Dänzer
2016-12-01  7:37                         ` [PATCH v2] " Michel Dänzer
2016-12-01 14:46                           ` Alex Deucher
2016-12-05  8:05                             ` Daniel Vetter
2016-12-01 15:21                           ` Sean Paul
2016-12-01 15:23                             ` Daniel Vetter
2016-11-30  9:13                     ` [PATCH 1/2] drm: Don't call drm_for_each_crtc " Daniel Vetter

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=20161130083002.1520-1-michel@daenzer.net \
    --to=michel@daenzer.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dvyukov@google.com \
    /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).