Skip to content

Commit 75ae95a

Browse files
David Herrmanndanvet
authored andcommitted
drm: remove redundant drm_file->uid
Each DRM file-context caches the EUID of the process that opened the file. It is used exclusively for debugging purposes in /proc/dri/ and friends. Note, however, that we can already fetch the EUID from priv->pid->task->creds. The pointer-chasing will not hurt us, since it is only about debugging, anyway. Since we already are in an rcu-read-side, we can use __task_cred() rather than task_cred_xxx(). Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20160901124837.680-2-dh.herrmann@gmail.com
1 parent 9f8cf16 commit 75ae95a

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/gpu/drm/drm_fops.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor)
199199

200200
filp->private_data = priv;
201201
priv->filp = filp;
202-
priv->uid = current_euid();
203202
priv->pid = get_pid(task_pid(current));
204203
priv->minor = minor;
205204

‎drivers/gpu/drm/drm_info.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ int drm_clients_info(struct seq_file *m, void *data)
8080
struct drm_info_node *node = (struct drm_info_node *) m->private;
8181
struct drm_device *dev = node->minor->dev;
8282
struct drm_file *priv;
83+
kuid_t uid;
8384

8485
seq_printf(m,
8586
"%20s %5s %3s master a %5s %10s\n",
@@ -98,13 +99,14 @@ int drm_clients_info(struct seq_file *m, void *data)
9899

99100
rcu_read_lock(); /* locks pid_task()->comm */
100101
task = pid_task(priv->pid, PIDTYPE_PID);
102+
uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID;
101103
seq_printf(m, "%20s %5d %3d %c %c %5d %10u\n",
102104
task ? task->comm : "<unknown>",
103105
pid_vnr(priv->pid),
104106
priv->minor->index,
105107
drm_is_current_master(priv) ? 'y' : 'n',
106108
priv->authenticated ? 'y' : 'n',
107-
from_kuid_munged(seq_user_ns(m), priv->uid),
109+
from_kuid_munged(seq_user_ns(m), uid),
108110
priv->magic);
109111
rcu_read_unlock();
110112
}

‎include/drm/drmP.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ struct drm_file {
379379
unsigned is_master:1;
380380

381381
struct pid *pid;
382-
kuid_t uid;
383382
drm_magic_t magic;
384383
struct list_head lhead;
385384
struct drm_minor *minor;

0 commit comments

Comments
 (0)