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: 10097121 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 72615602BF for ; Wed, 6 Dec 2017 20:28:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 631B229D99 for ; Wed, 6 Dec 2017 20:28:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56A7629F25; Wed, 6 Dec 2017 20:28:57 +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=ham 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 2384F29D99 for ; Wed, 6 Dec 2017 20:28:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A00F6E722; Wed, 6 Dec 2017 20:28:55 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@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 709666E1D7 for ; Wed, 6 Dec 2017 20:28:54 +0000 (UTC) Received: by mail-pf0-x242.google.com with SMTP id a90so2899424pfk.1 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=WsSen1g4etWiXBPQLKvDURVsilIUYNTwbE9+HcF3qoZqMbVg3hEur70KujabqPmnAA 4MRW8taLw/SnphWs4zAdTTpiIPsYsZsQ8uej94rV7UUn79TOkuZZVFXNVd7QQNYUJ05J hRwstnWQj0lJVOWqjiB/DOH9bn0GMMhA7aOmc32rGhAha6K9YB8muEI4nzmBpmGose78 bz6D4rsNWVgiBqpXoNX98AuNycnoQ0yL1EUOHNIcIfjTlyDG8Q2a99M3scjkm8g5lGCO CXZ0HN7qq61zluD6hCfo497qKvpGWOd6YEMfhrzlHoyyDA822xVoqCPGgc2c+IRAze0c MH5w== X-Gm-Message-State: AJaThX4wX0Q6Qh7WFPlEwZtG7DvJJFp/rx2sK9DrPaDQhlKPpsUMFebM 5f5pDzV7sDjHiYlC0MHNnGq3ug== 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 Message-ID: <20171206202850.GA38365@beast> MIME-Version: 1.0 Content-Disposition: inline Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH] drm/i915: Use copy_from_user() in fence copying 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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; }