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

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