From: David Herrmann <dh.herrmann@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 2/8] drm: remove redundant drm_file->uid
Date: Wed, 3 Aug 2016 20:04:26 +0200 [thread overview]
Message-ID: <20160803180432.1341-3-dh.herrmann@gmail.com> (raw)
In-Reply-To: <20160803180432.1341-1-dh.herrmann@gmail.com>
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 "struct file" already caches the credentials of a
process at open-time. So lets just use drm_file->filp->f_cred->euid if
available. The pointer-chasing will not hurt us, since it is only about
debugging, anyway.
Check priv->filp for NULL before deref, to prepare for in-kernel contexts
(if they ever appear). We should not rely on "struct file" contexts to be
around at all times, anyway.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
drivers/gpu/drm/drm_fops.c | 1 -
drivers/gpu/drm/drm_info.c | 4 +++-
drivers/gpu/drm/drm_ioctl.c | 4 +++-
include/drm/drmP.h | 1 -
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 323c238..e9d66f5 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -199,7 +199,6 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor)
filp->private_data = priv;
priv->filp = filp;
- priv->uid = current_euid();
priv->pid = get_pid(task_pid(current));
priv->minor = minor;
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index 9ae353f..247ba2b 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -80,6 +80,7 @@ int drm_clients_info(struct seq_file *m, void *data)
struct drm_info_node *node = (struct drm_info_node *) m->private;
struct drm_device *dev = node->minor->dev;
struct drm_file *priv;
+ kuid_t uid;
seq_printf(m,
"%20s %5s %3s master a %5s %10s\n",
@@ -98,13 +99,14 @@ int drm_clients_info(struct seq_file *m, void *data)
rcu_read_lock(); /* locks pid_task()->comm */
task = pid_task(priv->pid, PIDTYPE_PID);
+ uid = priv->filp ? priv->filp->f_cred->euid : GLOBAL_ROOT_UID;
seq_printf(m, "%20s %5d %3d %c %c %5d %10u\n",
task ? task->comm : "<unknown>",
pid_vnr(priv->pid),
priv->minor->index,
drm_is_current_master(priv) ? 'y' : 'n',
priv->authenticated ? 'y' : 'n',
- from_kuid_munged(seq_user_ns(m), priv->uid),
+ from_kuid_munged(seq_user_ns(m), uid),
priv->magic);
rcu_read_unlock();
}
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 33af4a5..49cd835 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -191,7 +191,9 @@ static int drm_getclient(struct drm_device *dev, void *data,
client->auth = file_priv->authenticated;
client->pid = pid_vnr(file_priv->pid);
client->uid = from_kuid_munged(current_user_ns(),
- file_priv->uid);
+ file_priv->filp ?
+ file_priv->filp->f_cred->euid :
+ GLOBAL_ROOT_UID);
client->magic = 0;
client->iocs = 0;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d488a72..0f69f56 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -320,7 +320,6 @@ struct drm_file {
unsigned is_master:1;
struct pid *pid;
- kuid_t uid;
drm_magic_t magic;
struct list_head lhead;
struct drm_minor *minor;
--
2.9.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-08-03 18:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-03 18:04 [PATCH 0/8] DRM File Context Cleanups David Herrmann
2016-08-03 18:04 ` [PATCH 1/8] drm: rename DRM_MINOR_LEGACY to DRM_MINOR_PRIMARY David Herrmann
2016-08-04 7:45 ` Frank Binns
2016-08-04 8:16 ` Daniel Vetter
2016-08-03 18:04 ` David Herrmann [this message]
2016-08-03 18:57 ` [PATCH 2/8] drm: remove redundant drm_file->uid Chris Wilson
2016-08-03 19:01 ` Chris Wilson
2016-08-04 8:29 ` David Herrmann
2016-08-03 18:04 ` [PATCH 3/8] drm: reduce GETCLIENT to a minimum David Herrmann
2016-08-03 18:04 ` [PATCH 4/8] drm: make vma-manager entries untyped David Herrmann
2016-08-03 18:51 ` Chris Wilson
2016-08-04 9:29 ` Emil Velikov
2016-08-03 18:04 ` [PATCH 5/8] drm: use drm_file to tag vm-bos David Herrmann
2016-08-03 19:08 ` Chris Wilson
2016-08-04 8:16 ` Daniel Vetter
2016-08-04 8:30 ` David Herrmann
2016-08-03 18:04 ` [PATCH 6/8] drm: use priv->pid to deduce task EUID David Herrmann
2016-08-03 18:58 ` Chris Wilson
2016-08-03 18:04 ` [PATCH 7/8] drm: rename drm_file.filp to drm_file.legacy_filp David Herrmann
2016-08-03 18:04 ` [PATCH 8/8] drm: provide management functions for drm_file David Herrmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160803180432.1341-3-dh.herrmann@gmail.com \
--to=dh.herrmann@gmail.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox