diff mbox

[6/8] drm: use priv->pid to deduce task EUID

Message ID 20160803180432.1341-7-dh.herrmann@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Herrmann Aug. 3, 2016, 6:04 p.m. UTC
Rather than accessing priv->filp->f_cred, use priv->pid->task->creds. We
want to get rid of "priv->filp", so lets avoid it if possible.

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>
---
 drivers/gpu/drm/drm_info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chris Wilson Aug. 3, 2016, 6:58 p.m. UTC | #1
On Wed, Aug 03, 2016 at 08:04:30PM +0200, David Herrmann wrote:
> Rather than accessing priv->filp->f_cred, use priv->pid->task->creds. We
> want to get rid of "priv->filp", so lets avoid it if possible.
> 
> 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>
> ---
>  drivers/gpu/drm/drm_info.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
> index 247ba2b..1df2d33 100644
> --- a/drivers/gpu/drm/drm_info.c
> +++ b/drivers/gpu/drm/drm_info.c
> @@ -99,7 +99,7 @@ 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;
> +		uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID;

Squash this into patch 2, so the poor reader doesn't have to learn about
f_cred.
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index 247ba2b..1df2d33 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -99,7 +99,7 @@  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;
+		uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID;
 		seq_printf(m, "%20s %5d %3d   %c    %c %5d %10u\n",
 			   task ? task->comm : "<unknown>",
 			   pid_vnr(priv->pid),