drm/vmwgfx: Allow dropped masters render-node like access on legacy nodes v2
authorThomas Hellstrom <thellstrom@vmware.com>
Thu, 27 Aug 2015 17:06:24 +0000 (10:06 -0700)
committerThomas Hellstrom <thellstrom@vmware.com>
Tue, 1 Sep 2015 09:06:02 +0000 (02:06 -0700)
Applications like gnome-shell may try to render after dropping master
privileges. Since the driver should now be safe against this scenario,
allow those applications to use their legacy node like a render node.

v2: Add missing return statement.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c

index 03854d606d589bd6730423e34aa48e5f1c388c13..e13b20bd9908d65b4b906d11f2a9d3aae0d8e847 100644 (file)
@@ -1052,10 +1052,15 @@ static struct vmw_master *vmw_master_check(struct drm_device *dev,
        }
 
        /*
-        * Check if we were previously master, but now dropped.
+        * Check if we were previously master, but now dropped. In that
+        * case, allow at least render node functionality.
         */
        if (vmw_fp->locked_master) {
                mutex_unlock(&dev->master_mutex);
+
+               if (flags & DRM_RENDER_ALLOW)
+                       return NULL;
+
                DRM_ERROR("Dropped master trying to access ioctl that "
                          "requires authentication.\n");
                return ERR_PTR(-EACCES);
index 5b8595b784296d80c9b27f91a874f12a4f750b9c..3361769842f4d91a3b7dc68a3e2818c2572d75a8 100644 (file)
@@ -911,6 +911,12 @@ vmw_surface_handle_reference(struct vmw_private *dev_priv,
                                  "surface reference.\n");
                        return -EACCES;
                }
+               if (ACCESS_ONCE(vmw_fpriv(file_priv)->locked_master)) {
+                       DRM_ERROR("Locked master refused legacy "
+                                 "surface reference.\n");
+                       return -EACCES;
+               }
+
                handle = u_handle;
        }