From patchwork Sun Oct 20 16:55:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 3073491 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 1F74C9F396 for ; Sun, 20 Oct 2013 16:59:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3FE2A2027C for ; Sun, 20 Oct 2013 16:59:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6460720258 for ; Sun, 20 Oct 2013 16:59:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 52C46E7161 for ; Sun, 20 Oct 2013 09:59:12 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ee0-f41.google.com (mail-ee0-f41.google.com [74.125.83.41]) by gabe.freedesktop.org (Postfix) with ESMTP id 44A71E7184 for ; Sun, 20 Oct 2013 09:56:03 -0700 (PDT) Received: by mail-ee0-f41.google.com with SMTP id d49so53367eek.28 for ; Sun, 20 Oct 2013 09:56:02 -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=IaNXSmo/C8/yay8mAxySzLQBBMucjG1w9V2fx9rv8YU=; b=Z47CBRcMw1UQ/CcnIAjx/fYninCac+CDec14P7PwCFolTwfLWnPbYeLQgVkKaAj2fX PBa7La9hfu7DXMlMa3y8an0EVhYQXZVs7i2YsaBueTiE93wTS2ehv2UYDjhEYQfXlj9R niCl7Xe85ytY2v3JoQuRros2yTntkxNBx1/VRjMPHgcLY87ssCEN9oN9c1wVNK6sYoMu K7uXHX6nUC/N0+gPPdCjFiJ5g5O8ENz+D2BP/Rf+UuG6HOtc5aN446SYiFK4Q3ENBtxB 8nQHXvFDnrB5jz6SmQQG2e1yQ0LydbauVlpIftYDWywo8H40VAWD/mZiQyOgaGqUz7MN gwaQ== X-Received: by 10.14.42.6 with SMTP id i6mr452553eeb.65.1382288162434; Sun, 20 Oct 2013 09:56:02 -0700 (PDT) Received: from localhost.localdomain (stgt-5f71a68b.pool.mediaWays.net. [95.113.166.139]) by mx.google.com with ESMTPSA id e13sm32704479eeu.4.2013.10.20.09.56.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Oct 2013 09:56:01 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/6] drm: remove minor-id during unplug Date: Sun, 20 Oct 2013 18:55:44 +0200 Message-Id: <1382288145-1776-5-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.4.1 In-Reply-To: <1382288145-1776-1-git-send-email-dh.herrmann@gmail.com> References: <1382288145-1776-1-git-send-email-dh.herrmann@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.5 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 Don't delay minor removal to drm_put_minor(). Otherwise, user-space can still open the minor and cause the kernel to oops. Instead, remove the minor during unplug so any new open() will fail to access this minor. Note that open() and drm_unplug_minor() are both protected by the global DRM mutex so we're fine. Signed-off-by: David Herrmann --- drivers/gpu/drm/drm_stub.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index 5bf4339..4bb80cf 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c @@ -346,6 +346,7 @@ static void drm_unplug_minor(struct drm_minor *minor) #endif drm_sysfs_device_remove(minor); + idr_remove(&drm_minors_idr, minor->index); } /** @@ -365,9 +366,6 @@ static void drm_put_minor(struct drm_minor *minor) DRM_DEBUG("release secondary minor %d\n", minor->index); drm_unplug_minor(minor); - - idr_remove(&drm_minors_idr, minor->index); - kfree(minor); }