drm: Do not drop root privileges for a fancier younger process
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 29 Oct 2013 08:55:57 +0000 (08:55 +0000)
committerDave Airlie <airlied@redhat.com>
Wed, 6 Nov 2013 04:27:35 +0000 (14:27 +1000)
When a second process opens the device and master transferrence is
complete, we walk the list of open devices and remove their
authentication. This also revokes our root privilege. Instead of simply
dropping the authentication, this patch reverts the authenticated state
back to its original value.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_fops.c
include/drm/drmP.h

index ee2d330a2fa0740b645debf9a14eeb7180fcbbd7..3a7176ce25402a1e5beb43e4cf65374bd29c13fa 100644 (file)
@@ -239,7 +239,8 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
 
        priv->ioctl_count = 0;
        /* for compatibility root is always authenticated */
-       priv->authenticated = capable(CAP_SYS_ADMIN);
+       priv->always_authenticated = capable(CAP_SYS_ADMIN);
+       priv->authenticated = priv->always_authenticated;
        priv->lock_count = 0;
 
        INIT_LIST_HEAD(&priv->lhead);
@@ -533,7 +534,7 @@ int drm_release(struct inode *inode, struct file *filp)
                list_for_each_entry(temp, &dev->filelist, lhead) {
                        if ((temp->master == file_priv->master) &&
                            (temp != file_priv))
-                               temp->authenticated = 0;
+                               temp->authenticated = temp->always_authenticated;
                }
 
                /**
index 444751b9aa89b5aedd8f549066ef1fea772f7820..ea8bff3c846838aa0e6bbc6f4a41578ca220196c 100644 (file)
@@ -413,6 +413,7 @@ struct drm_prime_file_private {
 
 /** File private data */
 struct drm_file {
+       int always_authenticated;
        int authenticated;
        struct pid *pid;
        kuid_t uid;