From patchwork Mon May 13 23:58:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Lutomirski X-Patchwork-Id: 2561211 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A6C06DF2E5 for ; Mon, 13 May 2013 23:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755620Ab3EMX72 (ORCPT ); Mon, 13 May 2013 19:59:28 -0400 Received: from mail-da0-f52.google.com ([209.85.210.52]:50400 "EHLO mail-da0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755728Ab3EMX7Z (ORCPT ); Mon, 13 May 2013 19:59:25 -0400 Received: by mail-da0-f52.google.com with SMTP id o9so2606963dan.25 for ; Mon, 13 May 2013 16:59:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:x-gm-message-state; bh=9/tnnrx0d9SXwj+qFVvKA5KvNkk0eT2Kmqqu71BcNys=; b=KoZFViwoEdCBBKMa7ClYSmBGS1tD05zXqJEfMkulKKkNj4QCi45/SZxciAhxVebyvv XP+vWCsFalLGbD+D98rcscqgGGs9k5cPyH4q71gIgI0RO46VLuGc4kY1cvBjTFiLFDAj pBK3Ms1Hh1rXXz9FK5rTDw+u6J3MSHTWhp/F2AjbBVWUPiOhSiffq0+pwDkVDGkq6fDB mH5WyAp9gpGWR1rv1e9cy5q+9PKsiZxXZpVoz45dgXVTCBHo/18w+2IGhTe8uC6pOUYF bbhw7UhmYnZa703XMPNnrHAY1DGNGn+VNb325XHcFMHgnF2m3GvlQVc65yfwsXdNkV1F fpUA== X-Received: by 10.68.129.10 with SMTP id ns10mr31604206pbb.13.1368489564890; Mon, 13 May 2013 16:59:24 -0700 (PDT) Received: from localhost (50-76-60-73-ip-static.hfc.comcastbusiness.net. [50.76.60.73]) by mx.google.com with ESMTPSA id xu10sm4416126pab.3.2013.05.13.16.59.22 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 13 May 2013 16:59:23 -0700 (PDT) From: Andy Lutomirski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org Cc: Daniel Vetter , Jerome Glisse , Alex Deucher , Dave Airlie , Andy Lutomirski Subject: [PATCH v3 9/9] drm: Don't leak phys_wc "handles" to userspace Date: Mon, 13 May 2013 16:58:48 -0700 Message-Id: <49cb9bfb3edeaf86ec659f1722893ddbd31075c4.1368485053.git.luto@amacapital.net> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQkGJhek4S9cnw7IClm+WkRkLD6Yj+nP2E/OWsAY8rljprPu1jg55qTiEHo6q/QZItcNCZ3t Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org I didn't fix this in the earlier patch -- it would have broken the build due to the now-deleted garbage in drm_os_linux.h. Reviewed-by: Daniel Vetter Signed-off-by: Andy Lutomirski --- drivers/gpu/drm/drm_bufs.c | 9 +++++++++ drivers/gpu/drm/drm_ioctl.c | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index 0190fce..5a4dbb4 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -414,6 +414,15 @@ int drm_addmap_ioctl(struct drm_device *dev, void *data, /* avoid a warning on 64-bit, this casting isn't very nice, but the API is set so too late */ map->handle = (void *)(unsigned long)maplist->user_token; + + /* + * It appears that there are no users of this value whatsoever -- + * drmAddMap just discards it. Let's not encourage its use. + * (Keeping drm_addmap_core's returned mtrr value would be wrong -- + * it's not a real mtrr index anymore.) + */ + map->mtrr = -1; + return 0; } diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index e77bd8b..ffd7a7b 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -38,6 +38,9 @@ #include #include +#ifdef CONFIG_X86 +#include +#endif /** * Get the bus id. @@ -181,7 +184,17 @@ int drm_getmap(struct drm_device *dev, void *data, map->type = r_list->map->type; map->flags = r_list->map->flags; map->handle = (void *)(unsigned long) r_list->user_token; - map->mtrr = r_list->map->mtrr; + +#ifdef CONFIG_X86 + /* + * There appears to be exactly one user of the mtrr index: dritest. + * It's easy enough to keep it working on non-PAT systems. + */ + map->mtrr = phys_wc_to_mtrr_index(r_list->map->mtrr); +#else + map->mtrr = -1; +#endif + mutex_unlock(&dev->struct_mutex); return 0;