Blame SOURCES/0001-dri-add-another-get-shm-variant.patch

da8ecd
From 7881d29f2c729e4a8a5af21a0abcf3db18e22918 Mon Sep 17 00:00:00 2001
da8ecd
From: Dave Airlie <airlied@redhat.com>
da8ecd
Date: Fri, 14 Feb 2020 15:00:13 +1000
da8ecd
Subject: [PATCH 1/2] dri: add another get shm variant.
da8ecd
da8ecd
When Brian in 02c3dad0f3b4d26e0faa5cc51d06bc50d693dcdc restricted
da8ecd
the shm permissions it means we hit the fallback paths in some
da8ecd
scenarios we hadn't before.
da8ecd
da8ecd
When you use Xephyr to xdmcp from one user to another the new perms
da8ecd
stop the X server (running as user a) attaching to the SHM segments
da8ecd
from gnome-shell (running as user b).
da8ecd
da8ecd
In this case however only the GLX side of the code had insight into this,
da8ecd
and the dri could was meant of fall back, and it worked for put image
da8ecd
fine but the get image path was broken, since there was no indication
da8ecd
in the broken case of the need to fallback.
da8ecd
da8ecd
This adds a return type to a new interface member that lets the
da8ecd
caller know it has to fallback.
da8ecd
da8ecd
Fixes: 02c3dad0f3b4 ("Call shmget() with permission 0600 instead of 0777")
da8ecd
---
da8ecd
 include/GL/internal/dri_interface.h    | 15 ++++++++++++++-
da8ecd
 src/gallium/state_trackers/dri/drisw.c |  3 +++
da8ecd
 2 files changed, 17 insertions(+), 1 deletion(-)
da8ecd
da8ecd
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
da8ecd
index 09782c8baeb..e40106575c0 100644
da8ecd
--- a/include/GL/internal/dri_interface.h
da8ecd
+++ b/include/GL/internal/dri_interface.h
da8ecd
@@ -634,7 +634,7 @@ struct __DRIdamageExtensionRec {
da8ecd
  * SWRast Loader extension.
da8ecd
  */
da8ecd
 #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
da8ecd
-#define __DRI_SWRAST_LOADER_VERSION 5
da8ecd
+#define __DRI_SWRAST_LOADER_VERSION 6
da8ecd
 struct __DRIswrastLoaderExtensionRec {
da8ecd
     __DRIextension base;
da8ecd
 
da8ecd
@@ -711,6 +711,19 @@ struct __DRIswrastLoaderExtensionRec {
da8ecd
                          int width, int height, int stride,
da8ecd
                          int shmid, char *shmaddr, unsigned offset,
da8ecd
                          void *loaderPrivate);
da8ecd
+
da8ecd
+    /**
da8ecd
+     * get shm image to drawable (v2)
da8ecd
+     *
da8ecd
+     * There are some cases where GLX can't use SHM, but DRI
da8ecd
+     * still tries, we need to get a return type for when to
da8ecd
+     * fallback to the non-shm path.
da8ecd
+     *
da8ecd
+     * \since 6
da8ecd
+     */
da8ecd
+    GLboolean (*getImageShm2)(__DRIdrawable *readable,
da8ecd
+                              int x, int y, int width, int height,
da8ecd
+                              int shmid, void *loaderPrivate);
da8ecd
 };
da8ecd
 
da8ecd
 /**
da8ecd
diff --git a/src/gallium/state_trackers/dri/drisw.c b/src/gallium/state_trackers/dri/drisw.c
da8ecd
index e3fb3f1b925..df364c47391 100644
da8ecd
--- a/src/gallium/state_trackers/dri/drisw.c
da8ecd
+++ b/src/gallium/state_trackers/dri/drisw.c
da8ecd
@@ -138,6 +138,9 @@ get_image_shm(__DRIdrawable *dPriv, int x, int y, int width, int height,
da8ecd
    if (!res->screen->resource_get_handle(res->screen, NULL, res, &whandle, PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE))
da8ecd
       return FALSE;
da8ecd
 
da8ecd
+   if (loader->base.version > 5 && loader->getImageShm2)
da8ecd
+      return loader->getImageShm2(dPriv, x, y, width, height, whandle.handle, dPriv->loaderPrivate);
da8ecd
+
da8ecd
    loader->getImageShm(dPriv, x, y, width, height, whandle.handle, dPriv->loaderPrivate);
da8ecd
    return TRUE;
da8ecd
 }
da8ecd
-- 
da8ecd
2.21.1
da8ecd