From patchwork Thu Apr 23 14:07:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Antoine X-Patchwork-Id: 6263051 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0929E9F1BE for ; Thu, 23 Apr 2015 14:08:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB3C0203AB for ; Thu, 23 Apr 2015 14:08:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 85AD5203A0 for ; Thu, 23 Apr 2015 14:08:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 13D7F6E795; Thu, 23 Apr 2015 07:08:15 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id D9A8B6E796; Thu, 23 Apr 2015 07:08:13 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 23 Apr 2015 07:08:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,631,1422950400"; d="scan'208";a="684541277" Received: from peterant-linux.isw.intel.com ([10.102.226.72]) by orsmga001.jf.intel.com with ESMTP; 23 Apr 2015 07:08:11 -0700 From: Peter Antoine To: intel-gfx@lists.freedesktop.org Date: Thu, 23 Apr 2015 15:07:55 +0100 Message-Id: <1429798078-18987-3-git-send-email-peter.antoine@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429798078-18987-1-git-send-email-peter.antoine@intel.com> References: <1429798078-18987-1-git-send-email-peter.antoine@intel.com> Cc: airlied@redhat.com, dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch Subject: [Intel-gfx] [PATCH 2/5] drm: Fixes unsafe deference in locks. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 This patch fixes an unsafe deference in the DRM_IOCTL_NEW_CTX. If the ioctl is called before the lock is created or after it has been destroyed. The code will deference a NULL pointer. This ioctl is a root ioctl so exploitation is limited. Issue: VIZ-5485 Signed-off-by: Peter Antoine --- drivers/gpu/drm/drm_context.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c index 9b23525..96350d1 100644 --- a/drivers/gpu/drm/drm_context.c +++ b/drivers/gpu/drm/drm_context.c @@ -277,7 +277,13 @@ static int drm_context_switch_complete(struct drm_device *dev, { dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ - if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) { + if (file_priv->master->lock.hw_lock == NULL) { + DRM_ERROR( + "Device has been unregistered. Hard exit. Process %d\n", + task_pid_nr(current)); + send_sig(SIGTERM, current, 0); + return -EPERM; + } else if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) { DRM_ERROR("Lock isn't held after context switch\n"); }