From patchwork Thu Sep 1 12:48:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 9309007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6803C607D6 for ; Thu, 1 Sep 2016 12:48:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63B0A29383 for ; Thu, 1 Sep 2016 12:48:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 563DB29386; Thu, 1 Sep 2016 12:48:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 025F029386 for ; Thu, 1 Sep 2016 12:48:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A27E6E2BC; Thu, 1 Sep 2016 12:48:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7AD476E2BC for ; Thu, 1 Sep 2016 12:48:51 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id w207so8276565wmw.0 for ; Thu, 01 Sep 2016 05:48:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WVbydOhIWRA+PGQZvmiV1ZPGgScRPPv57lB9WuFR328=; b=ERS6KUNz07ASlgEHSx/v9Hy8S8Yg3ufmclCTZNrUVngzFPfbWFfn77G6IurZFKUGCz k9cZTVyXZgQLkfFKGn/1LvFzuaeouriWWqnc59XmoHKqQdlhQdAIL3uVKV2+HSMdOb1y f++oyJC5AZNbsExrRtY43HofCBpwEqJF27vkmhKkJ7fPOz+gbGBC++BNad+0K/EJCPvf O/0o+GBXVvm866tMuoCH5rWgU4ZJ/xRAate1bu3Z26sO7TF2+Qyf4gn+M61MUEGcc0XV /2VLrD+B7Ri6Rt79PmOQYc+GmSH0qm6sZJNLWqKt/qJBh0whUMpMdhkMmbyjBAnwUtBS CTzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WVbydOhIWRA+PGQZvmiV1ZPGgScRPPv57lB9WuFR328=; b=Et75PJHmczToPpeBQWURu8lVw7SELa/+mBiMPQ+12yiJAh/Wo7w7M/LWcXB5dNDOPE KK50KTCugHo3l0C/RdGXj5Qb/aXTXVYricmDVGZx1REnlbSYOJcFsy5aWEavnSlqu/Ec xZZKewe+FyWKyvJkDcpXvTyGuD4J/UX0vhRWLajxoCgI65F9cbHA9nr6uaw68yYCnSgT vkhMIHeWVSupImjWg9aQ8OayotasK6owtkIFcx2jPinibhJMxFoFlYUuB2Fge4csDf8C uQDDdOPHPFbUJkrKsIJwoyWkdS9B6jnzCMWNSPbt39TA8dr3yvSAoGoEnG9TFO3JQfT4 4GsQ== X-Gm-Message-State: AE9vXwM2NOUdbpyotcu13im91zNhEzRkyCS4JGmHNkzi93FNjgqnoZz4tqgu2Kx3Ai6tMg== X-Received: by 10.28.99.86 with SMTP id x83mr27151754wmb.95.1472734130013; Thu, 01 Sep 2016 05:48:50 -0700 (PDT) Received: from localhost.localdomain ([37.120.86.93]) by smtp.gmail.com with ESMTPSA id i8sm14287786wmg.21.2016.09.01.05.48.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Sep 2016 05:48:49 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/6] drm: remove redundant drm_file->uid Date: Thu, 1 Sep 2016 14:48:32 +0200 Message-Id: <20160901124837.680-2-dh.herrmann@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160901124837.680-1-dh.herrmann@gmail.com> References: <20160901124837.680-1-dh.herrmann@gmail.com> Cc: Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/gpu/drm/drm_fops.c | 1 - drivers/gpu/drm/drm_info.c | 4 +++- include/drm/drmP.h | 1 - 3 files changed, 3 insertions(+), 3 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..1df2d33 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 = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID; seq_printf(m, "%20s %5d %3d %c %c %5d %10u\n", task ? task->comm : "", 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/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;