From patchwork Wed Aug 3 18:04:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 9261697 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 9B9F660754 for ; Wed, 3 Aug 2016 18:05:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9213C28236 for ; Wed, 3 Aug 2016 18:05:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8705028307; Wed, 3 Aug 2016 18:05: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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 386F328236 for ; Wed, 3 Aug 2016 18:05:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3BD556E894; Wed, 3 Aug 2016 18:05:15 +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 8EC776E894 for ; Wed, 3 Aug 2016 18:05:00 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id i5so37519038wmg.2 for ; Wed, 03 Aug 2016 11:05:00 -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=i0jZt85LxZ5RaYwgveoPkedxVpD/ZWTNE0O9qFRbCJY=; b=oMhxwWMSn9xXYnOpCKUyn7jtTXfXumvDlv/JgHe1uUW/NSeZsS4UM9mC3XCIyUIr52 A2Drs9m4HzMmSnkDV6+dvfkWUqKRi2TZykwsCSai7lc4eeS5C/oeKRZIKwBhF5/MO40g cShQ+wDhytkhaR3aLrYSgu8uwdZ96NOzeQdVQUXddEXzP0Bheh/ROYloXlzNYZqmh1GY USo8S1m57pOcbO3PfTsBACTEjTTvKxgD82qyxaj0y9UzhybLoo6L0baAVtffSeZerW8Q /dm4l3rq02CeLYl63uMrEijUVMB0ZKDTk2aRtW9wys3+a+WjYGJpw7fORdN7pAe6G62d rERQ== 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=i0jZt85LxZ5RaYwgveoPkedxVpD/ZWTNE0O9qFRbCJY=; b=SkvsqpTG7OoJngNNpLVL+GUCPUpIouAAMGb7FJmEAuNSwnNcjw8fSWduG3+l0ioJ9J 1J+Dp20NV+MyWgezekEd2q9w/kne2xoC5U9hBlJpW5XkH1ETYUZcK3OSP4tcbOpghbkN m9Fl+XLPaYikdvmXMLKRH+thjwnMbQMUmfFhbA9jpEaZpZLW+IVfStO08FmkGhPpkO6A vvkeADFFZxl+dmL/1HDUlRaKKTRpvkAyBWb2YSgJdwqbyuBigaThGjOFigIhWzMQbZ8I Xf5ue8VL5OXHkvWA9r3uPdHV+JEgdqRvHTe1EqRnc+oebcibU4uIagbRXiFlOtylXEID uTiA== X-Gm-Message-State: AEkoouuGpGX2FZy90jvioDc2gpMtloQMlwgTCfPoJCmmmdtkpo7X9ygmCjyIxrVyEXdy2A== X-Received: by 10.28.222.8 with SMTP id v8mr26958392wmg.55.1470247497799; Wed, 03 Aug 2016 11:04:57 -0700 (PDT) Received: from localhost.localdomain ([37.120.18.65]) by smtp.gmail.com with ESMTPSA id va3sm8854296wjb.18.2016.08.03.11.04.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Aug 2016 11:04:56 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/8] drm: reduce GETCLIENT to a minimum Date: Wed, 3 Aug 2016 20:04:27 +0200 Message-Id: <20160803180432.1341-4-dh.herrmann@gmail.com> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20160803180432.1341-1-dh.herrmann@gmail.com> References: <20160803180432.1341-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 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 --- drivers/gpu/drm/drm_ioctl.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 49cd835..bc5c65e 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -189,11 +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->filp ? - file_priv->filp->f_cred->euid : - GLOBAL_ROOT_UID); + client->pid = task_pid_vnr(current); + client->uid = overflowuid; client->magic = 0; client->iocs = 0;