xserver: Branch 'master'

Michel Dänzer michel at daenzer.net
Tue Jun 8 00:57:44 PDT 2010


On Mon, 2010-06-07 at 11:28 -0700, Keith Packard wrote: 
> hw/xfree86/dri2/dri2.c |   10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> New commits:
> commit fdb081b430ddffb495aa5b05bcc4cf10882ff4b2
> Author: Keith Packard <keithp at keithp.com>
> Date:   Mon Jun 7 00:54:18 2010 -0700
> 
>     dri2: Deal with input-only windows by using WindowDrawable()
>     
>     Input only windows aren't DRAWABLE_WINDOW, but casting them to a
>     PixmapPtr is a bit harsh, and unlikely to get the appropriate privates
>     structure. use WindowDrawable instead which checks for both
>     input-output and input-only windows.
>     
>     Signed-off-by: Keith Packard <keithp at keithp.com>
>     Tested-by: Eric Anholt <eric at anholt.net>

FWIW, I would have proposed the patch below instead.


From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <daenzer at vmware.com>
Date: Tue, 8 Jun 2010 09:09:25 +0200
Subject: [PATCH] dri2: Only deal with output windows and pixmaps.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reject the creation of a DRI2 drawable for UNDRAWABLE_WINDOW (input-only
windows) and DRAWABLE_BUFFER (whatever those are) drawables and only look up
privates for the supported drawable types.

The rest of the the code can continue pretending there's only output windows
and pixmaps, which are the only kinds of drawables relevant for DRI2.

Fixes server crash with GLX compositing managers such as compiz or kwin, due
to looking up a window private for a pixmap and getting a bogus pointer.

Signed-off-by: Michel Dänzer <daenzer at vmware.com>
---
 hw/xfree86/dri2/dri2.c    |    7 +++++--
 hw/xfree86/dri2/dri2ext.c |    4 +++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index baa6706..abaf1c6 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -118,12 +118,15 @@ DRI2GetDrawable(DrawablePtr pDraw)
     WindowPtr pWin;
     PixmapPtr pPixmap;
 
-    if (pDraw->type == DRAWABLE_WINDOW) {
+    switch (pDraw->type) {
+    case DRAWABLE_WINDOW:
 	pWin = (WindowPtr) pDraw;
 	return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
-    } else {
+    case DRAWABLE_PIXMAP:
 	pPixmap = (PixmapPtr) pDraw;
 	return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
+    default:
+	return NULL;
     }
 }
 
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index db04268..e75c843 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -55,7 +55,9 @@ static Bool
 validDrawable(ClientPtr client, XID drawable, Mask access_mode,
 	      DrawablePtr *pDrawable, int *status)
 {
-    *status = dixLookupDrawable(pDrawable, drawable, client, 0, access_mode);
+    *status = dixLookupDrawable(pDrawable, drawable, client,
+				M_DRAWABLE_WINDOW | M_DRAWABLE_PIXMAP,
+				access_mode);
     if (*status != Success) {
 	client->errorValue = drawable;
 	return FALSE;
-- 
1.7.1



-- 
Earthling Michel Dänzer           |                http://www.vmware.com
Libre software enthusiast         |          Debian, X and DRI developer


More information about the xorg-devel mailing list