From patchwork Thu Aug 25 14:35:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 9299445 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 D0C0460459 for ; Thu, 25 Aug 2016 14:35:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C12E52934A for ; Thu, 25 Aug 2016 14:35:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1E282934E; Thu, 25 Aug 2016 14:35:27 +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 4E9E62934A for ; Thu, 25 Aug 2016 14:35:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 853156E9AE; Thu, 25 Aug 2016 14:35:24 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 97B046E9AE for ; Thu, 25 Aug 2016 14:35:22 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id o80so7715258wme.0 for ; Thu, 25 Aug 2016 07:35:22 -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; bh=Odak2fqynbgm2maejnDxTngXgfUHW4X8JUxWQItH6vM=; b=Bt9mM1+1Gu81sVQ21DtYxAgc1Ejonu5X1VfmOSMhVLo65WzainYmeVwP6UR2pg0fN3 R49NnChugUSV0Itt/3u1w03jhoEWHAof2xHkYYPdXzwf66Mja3hK/zTVG/sT3oNwWwYq qOg3hdW+NM7kCxISA5vyQwL2u05RmGXDGfnI8UkwUaA+UqGUSRQggjTVCluGvSANMLpQ Ry6P3JX9soygq4gpBx37ZPlVN5mYVfOcFqhZ/y8ufCdMczHYh3TPHUhcF09oHMgLo2L+ 0gwliWb8fikmtX2ljcg3/j2Guq5rts1o5QNMa37w76tIh2tRWcmxRktVnO1ljGRFduVZ 2V0A== 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; bh=Odak2fqynbgm2maejnDxTngXgfUHW4X8JUxWQItH6vM=; b=Fu/bI924GjUcvjk4sL/PIvghbKUpXfn5mufERna2oTt9QD3luCY1feY+3/u/RoM8AS ZOP4gPxiKMROjO45FAZWzfrnm51W2x42SUDPwUloqjL2BnAP00o+Cgvsb5mPJn9R3jdr 2bfVx4l5mWh2RQuJbqAiaKdacbj5FGsPsLZ6HNXmrP+03qT0AC6d+1ZrlMS1b2gXoauM /BtNgF8JOx9mkXSA2iKstHdxniqnYDqMrBYQkqjUCMyN9ncwBIE7b4WBskB9dJC1f4tO Vl9l5+Od/4kTKsE+82Cr6snyDpJV2jxZEvTKxHZku+ptublHrLsfmMJS3NMEDrNM2RpD B4wQ== X-Gm-Message-State: AEkoouuBE7DwN3IGIrts/4vSBPMAHLFWUpeQE/A4LHJ2TfPEtRwNAfCPAA0jaB3gaGajfQ== X-Received: by 10.28.209.134 with SMTP id i128mr28966601wmg.97.1472135720774; Thu, 25 Aug 2016 07:35:20 -0700 (PDT) Received: from localhost.localdomain ([37.120.99.16]) by smtp.gmail.com with ESMTPSA id s184sm39150260wmb.11.2016.08.25.07.35.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Aug 2016 07:35:19 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm: reduce GETCLIENT to a minimum Date: Thu, 25 Aug 2016 16:35:05 +0200 Message-Id: <20160825143505.7447-1-dh.herrmann@gmail.com> X-Mailer: git-send-email 2.9.3 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 The *only* known user of GETCLIENT is libva, which uses it to check whether its own context is authenticated. It used to iterate all clients, look for one that matches its own pid and then check its state. The entire purpose for us to still have a GETCLIENT implementation is to serve libva. So lets not pretend we do anything else: Make this function return information on the caller's context only, fake the PID to the caller's pid so they always match, and just fill in the "authenticated" bit, nothing else. This patch reduces the complexity of GETCLIENT to a bare minimum, avoids any dependency on priv->uid or priv->pid (allows us to get rid of them), and makes libva happy by always *exactly* returning the information it wants. Signed-off-by: David Herrmann --- v2: Just re-order the series and send individual patches, since they do not depend on each other. drivers/gpu/drm/drm_ioctl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 33af4a5..bc5c65e 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -189,9 +189,8 @@ static int drm_getclient(struct drm_device *dev, void *data, */ if (client->idx == 0) { client->auth = file_priv->authenticated; - client->pid = pid_vnr(file_priv->pid); - client->uid = from_kuid_munged(current_user_ns(), - file_priv->uid); + client->pid = task_pid_vnr(current); + client->uid = overflowuid; client->magic = 0; client->iocs = 0;