From patchwork Wed Jul 23 15:26:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 4611731 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C1A189F3B4 for ; Wed, 23 Jul 2014 15:30:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 038D020172 for ; Wed, 23 Jul 2014 15:30:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 04408201BC for ; Wed, 23 Jul 2014 15:30:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 536336E663; Wed, 23 Jul 2014 08:30:55 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-we0-f180.google.com (mail-we0-f180.google.com [74.125.82.180]) by gabe.freedesktop.org (Postfix) with ESMTP id B68796E663 for ; Wed, 23 Jul 2014 08:30:52 -0700 (PDT) Received: by mail-we0-f180.google.com with SMTP id w61so1358293wes.11 for ; Wed, 23 Jul 2014 08:30: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=A9+qa9DDops+HL7vhFHEees+i9/1z1PGCzG4AVdDcgY=; b=tuhxCLCBiA2kwn6AzK6WTKO8vGPXkL5OMUr++JiY2E6zms7xDBmXd0sENr6wr9sd5X 3tuLbcQaLPsDIi/pZmxoXNcH81zHf+pO/2aIMydOO7BtJamz0E2vBTaeAczpWzvtow6r XvOgcUka1v6H8m9OV/EShjSR9D1wnguASFueeDFSwekcBD2wxllXpfv+R8y4cZoeR2W9 O7xxsnXGLwmtYOE95nyd1nNXdUF/Yley5RyLzf7ApcQH2x79N+wNefXZcl88hVaUWi91 PxHwxegzeJAFkb9yXyJKNRa2t5yWbR7SZTdy+LZ2IDn1RCvI5nAa32bR5P1j4IUcvuvH TpTg== X-Received: by 10.194.48.103 with SMTP id k7mr3015885wjn.68.1406129451464; Wed, 23 Jul 2014 08:30:51 -0700 (PDT) Received: from david-tp.localdomain (stgt-5f71b1a8.pool.mediaWays.net. [95.113.177.168]) by mx.google.com with ESMTPSA id bx2sm7092580wjb.47.2014.07.23.08.30.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Jul 2014 08:30:50 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH 08/12] drm: don't de-authenticate clients on master-close Date: Wed, 23 Jul 2014 17:26:43 +0200 Message-Id: <1406129207-1302-9-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 2.0.2 In-Reply-To: <1406129207-1302-1-git-send-email-dh.herrmann@gmail.com> References: <1406129207-1302-1-git-send-email-dh.herrmann@gmail.com> Cc: Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If an active DRM-Master closes its device, we deauthenticate all clients on that master. However, if an inactive DRM-Master closes its device, we do nothing. This is quite inconsistent and breaks several scenarios: 1) If this was used as security mechanism, it fails horribly if a master closes a device while VT switched away. Furthermore, none of the few drivers using ->master_*() callbacks seems to require it, anyway. 2) If you spawn weston (or any other non-UMS compositor) in background while another compositor is active, both will get assigned to the same "drm_master" object. If the foreground compositor now exits, all clients of both the foreground AND background compositor will be de-authenticated leading to unexpected behavior. Stop this non-sense and keep clients authenticated. We don't do this when dropping DRM-Master (i.e., switching VTs) so don't do it on active-close either! Signed-off-by: David Herrmann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_fops.c | 13 ++----------- include/drm/drmP.h | 1 - 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index f65087e..ff0a13f 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -252,8 +252,7 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) priv->minor = minor; /* for compatibility root is always authenticated */ - priv->always_authenticated = capable(CAP_SYS_ADMIN); - priv->authenticated = priv->always_authenticated; + priv->authenticated = capable(CAP_SYS_ADMIN); priv->lock_count = 0; INIT_LIST_HEAD(&priv->lhead); @@ -453,20 +452,12 @@ int drm_release(struct inode *inode, struct file *filp) if (drm_is_master(file_priv)) { struct drm_master *master = file_priv->master; - struct drm_file *temp; - - mutex_lock(&dev->struct_mutex); - list_for_each_entry(temp, &dev->filelist, lhead) { - if ((temp->master == file_priv->master) && - (temp != file_priv)) - temp->authenticated = temp->always_authenticated; - } /** * Since the master is disappearing, so is the * possibility to lock. */ - + mutex_lock(&dev->struct_mutex); if (master->lock.hw_lock) { if (dev->sigdata.lock == master->lock.hw_lock) dev->sigdata.lock = NULL; diff --git a/include/drm/drmP.h b/include/drm/drmP.h index e1bb585..48d2fe7 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -385,7 +385,6 @@ struct drm_prime_file_private { /** File private data */ struct drm_file { - unsigned always_authenticated :1; unsigned authenticated :1; /* true when the client has asked us to expose stereo 3D mode flags */ unsigned stereo_allowed :1;