From patchwork Wed Dec 6 20:28:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10097811 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 F3F8F60325 for ; Thu, 7 Dec 2017 08:33:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E13E32A124 for ; Thu, 7 Dec 2017 08:33:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D60892A3B7; Thu, 7 Dec 2017 08:33:03 +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_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 832FC2A124 for ; Thu, 7 Dec 2017 08:33:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E3956E79F; Thu, 7 Dec 2017 08:32:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 709BE6E722 for ; Wed, 6 Dec 2017 20:28:54 +0000 (UTC) Received: by mail-pf0-x242.google.com with SMTP id m26so2882369pfj.11 for ; Wed, 06 Dec 2017 12:28:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=/O0n1zCZ3nkgX3iKXD7GIwJ59yOeizHk0JwtK0dHmjk=; b=nSIIJLiHoaf8t27H/aEUUtXsgwzAkHcwIX8r30Yk9iH+RhpjwL87Lvd95nxQFgHUq8 torLzO/zAuGu96TM1cUqR7mq4ejQENA3eFAtZdZLVSUq4XSnZxYJJ/mERUHQCd9W/eTh iRGmuWQsJplKjRCEeVCsan5rqyZTd2p9tJa5w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=/O0n1zCZ3nkgX3iKXD7GIwJ59yOeizHk0JwtK0dHmjk=; b=Cb1/00laDAN0d384VMtReWGbKqcsFyvN8Bh+EWHeGC2CQO68hgApSyft9Lk246jie2 EYq2CauxdWQYSJccsVD8JAl+jAghc6emdkeD2gTBYgUSnEChP4sswSde0+fP8kKGrTkJ NV1RhOjauSSg62jNVdYS2l5vdhCZrQwTxrvcgdE4tSuNM1CJEN/hNQ8vAo6HfoIMuyzy 8gVMoFrn3fMu+IZ6z5HQb84okF3obPjAMcHS0jMFQKUL957lYpbePfP6yOlTi5wrraCB sH5KK/N/OLVAk/sh20FEWyvqjIcq4azux0aD5r6iYCxfWhMqKNRP4aTAAM6+wpz9f/8O Jz/Q== X-Gm-Message-State: AJaThX6radfoS1dDBrqYcE9CnzNCbr9e9mUCDebjZ1SlRLpZPJe2gMwc 9iG0YoV4RJoqVgtfYTxWSMVzjw== X-Google-Smtp-Source: AGs4zMY6wt96o1c1UW0aTR/sbkzZ+DWpeSypZzgJqTL1tSY5FcrCqa+M6HAq+9M8G0piAZ5dnQeFvA== X-Received: by 10.84.168.227 with SMTP id f90mr22883050plb.320.1512592134026; Wed, 06 Dec 2017 12:28:54 -0800 (PST) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id w19sm6377215pfa.127.2017.12.06.12.28.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Dec 2017 12:28:52 -0800 (PST) Date: Wed, 6 Dec 2017 12:28:50 -0800 From: Kees Cook To: Jason Ekstrand Subject: [PATCH] drm/i915: Use copy_from_user() in fence copying Message-ID: <20171206202850.GA38365@beast> MIME-Version: 1.0 Content-Disposition: inline X-Mailman-Approved-At: Thu, 07 Dec 2017 08:32:57 +0000 Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP There's no good reason to separate the access_ok() from the copy, especially since the access_ok() size is hard-coded instead of using sizeof(). Instead, just use copy_from_user() directly. Fixes: cf6e7bac6357 ("drm/i915: Add support for drm syncobjs") Cc: Jason Ekstrand Cc: Chris Wilson Signed-off-by: Kees Cook --- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 435ed95df144..1da703213b17 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -2087,8 +2087,6 @@ get_fence_array(struct drm_i915_gem_execbuffer2 *args, return ERR_PTR(-EINVAL); user = u64_to_user_ptr(args->cliprects_ptr); - if (!access_ok(VERIFY_READ, user, nfences * 2 * sizeof(u32))) - return ERR_PTR(-EFAULT); fences = kvmalloc_array(args->num_cliprects, sizeof(*fences), __GFP_NOWARN | GFP_KERNEL); @@ -2099,7 +2097,7 @@ get_fence_array(struct drm_i915_gem_execbuffer2 *args, struct drm_i915_gem_exec_fence fence; struct drm_syncobj *syncobj; - if (__copy_from_user(&fence, user++, sizeof(fence))) { + if (copy_from_user(&fence, user++, sizeof(fence))) { err = -EFAULT; goto err; }