Skip to content

Commit 1020dc6

Browse files
ickleairlied
authored andcommitted
drm: Do not drop root privileges for a fancier younger process
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>
1 parent 33e3fd5 commit 1020dc6

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎drivers/gpu/drm/drm_fops.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
239239

240240
priv->ioctl_count = 0;
241241
/* for compatibility root is always authenticated */
242-
priv->authenticated = capable(CAP_SYS_ADMIN);
242+
priv->always_authenticated = capable(CAP_SYS_ADMIN);
243+
priv->authenticated = priv->always_authenticated;
243244
priv->lock_count = 0;
244245

245246
INIT_LIST_HEAD(&priv->lhead);
@@ -533,7 +534,7 @@ int drm_release(struct inode *inode, struct file *filp)
533534
list_for_each_entry(temp, &dev->filelist, lhead) {
534535
if ((temp->master == file_priv->master) &&
535536
(temp != file_priv))
536-
temp->authenticated = 0;
537+
temp->authenticated = temp->always_authenticated;
537538
}
538539

539540
/**

‎include/drm/drmP.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ struct drm_prime_file_private {
413413

414414
/** File private data */
415415
struct drm_file {
416+
int always_authenticated;
416417
int authenticated;
417418
struct pid *pid;
418419
kuid_t uid;

0 commit comments

Comments
 (0)