Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1447845ybb; Thu, 2 Apr 2020 00:35:58 -0700 (PDT) X-Google-Smtp-Source: APiQypKnziUPiO5rg/gRvVRMNotWq4CHgbUI6tTHx98936B3mehYKoZJJoZQE89tMhnXGnpzeFwX X-Received: by 2002:a9d:754e:: with SMTP id b14mr1368015otl.293.1585812957970; Thu, 02 Apr 2020 00:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585812957; cv=none; d=google.com; s=arc-20160816; b=NHPkUbsokjKAFpfEjjGqXsey1imuu7mQFGsJCiXOlPKzXGhNrXUIQg7pzP7fMJBtX5 /Z/97eZqoArT29Igtq4OMrsPUUeOG6pB4sQ8tITiDe7JpfeIbn8h2QFfm++oEn4ikHPj rjigNWAfarkv90sjVRUTH/H9FdjA8eYEZ6ZwFppT7P+2YrpSAUGkneTOaeyAxe1EsY9b +2VKIHcBFy+NobQPyA2LA9qAsky+DzbYN20c52VHSj0SZpDl+MVP/V7/PAw+Z/SOSDZ1 wPtc/It6NA47bo27xdg/AraaHb8qmqKNFb+1gjsGO1xcf++3T3P4mKb1/GlWZHfhYLzZ i+4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=EnNUuGCMz6bk/dO3z5czXXoQkB26spC2D2RLTxDm6dY=; b=Fy1Mu7YewTNkgy6l6IJ6lqG1wJ18R5YoNI170RaKGS1zgEUhIUH9zNyFTH9oZm11o/ pFbXdXq02xd2uiCfJNaxJphUUy8Q2QlZm92dPumSRhMh6NsE7lurQ0Dp8aEPicgygvPp 4HsyRvpi7JqjQyMphVYx+kZDVSkBhEiT1ghvk71v9LuYPVcB5QpfAqP3FRDBoR90jk4v XSBtWK6MfXsLi1klGhBr20vXBR8kkvPDkT2kFF+g1pE9Oug8CRFQCGU8ApRIsN2mRweP 0ItNGuczwI2BdB5qBq0jqjQZmca79cBXu8SqEQrPmwNf5J9OCwZIW0MYvWKmQ8prm58v 2vjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=tZ0wb+ZQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r7si1944203oij.4.2020.04.02.00.35.45; Thu, 02 Apr 2020 00:35:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=tZ0wb+ZQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387601AbgDBHeW (ORCPT + 99 others); Thu, 2 Apr 2020 03:34:22 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:21271 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387562AbgDBHeV (ORCPT ); Thu, 2 Apr 2020 03:34:21 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48tFF60bQTz9txL3; Thu, 2 Apr 2020 09:34:18 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=tZ0wb+ZQ; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id 1R7pAmPi39BZ; Thu, 2 Apr 2020 09:34:18 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48tFF56cN2z9txKx; Thu, 2 Apr 2020 09:34:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1585812857; bh=EnNUuGCMz6bk/dO3z5czXXoQkB26spC2D2RLTxDm6dY=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=tZ0wb+ZQyHLgTmXLJ8FEgt5OJA8l60TUwfuw0HeK4TWsAXbQmXnkOlCa+kpFC9Klt NGXGC8Pk+7k0DQXtb+4XaAVRQI695aXjOuMwdoZ0SbOOfqW/+Q2GgVmGIz5YfDYSWL XXGnecRWKOpfUpkooAxHdeT5W8Eysdj0Vc9+feqY= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D4D578B76E; Thu, 2 Apr 2020 09:34:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id krpMluquUZLm; Thu, 2 Apr 2020 09:34:18 +0200 (CEST) Received: from pc16570vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 985C88B75E; Thu, 2 Apr 2020 09:34:18 +0200 (CEST) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 68681656BF; Thu, 2 Apr 2020 07:34:18 +0000 (UTC) Message-Id: <6da6fa391c0d6344cc9ff99a69fcaa65666f3947.1585811416.git.christophe.leroy@c-s.fr> In-Reply-To: <27106d62fdbd4ffb47796236050e418131cb837f.1585811416.git.christophe.leroy@c-s.fr> References: <27106d62fdbd4ffb47796236050e418131cb837f.1585811416.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH RESEND 3/4] drm/i915/gem: Replace user_access_begin by user_write_access_begin To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , airlied@linux.ie, daniel@ffwll.ch, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, keescook@chromium.org, hpa@zytor.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-arch@vger.kernel.org Date: Thu, 2 Apr 2020 07:34:18 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When i915_gem_execbuffer2_ioctl() is using user_access_begin(), that's only to perform unsafe_put_user() so use user_write_access_begin() in order to only open write access. Signed-off-by: Christophe Leroy --- drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c index 7643a30ba4cd..4be8205a70b6 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c @@ -1611,14 +1611,14 @@ static int eb_copy_relocations(const struct i915_execbuffer *eb) * happened we would make the mistake of assuming that the * relocations were valid. */ - if (!user_access_begin(urelocs, size)) + if (!user_write_access_begin(urelocs, size)) goto end; for (copied = 0; copied < nreloc; copied++) unsafe_put_user(-1, &urelocs[copied].presumed_offset, end_user); - user_access_end(); + user_write_access_end(); eb->exec[i].relocs_ptr = (uintptr_t)relocs; } @@ -1626,7 +1626,7 @@ static int eb_copy_relocations(const struct i915_execbuffer *eb) return 0; end_user: - user_access_end(); + user_write_access_end(); end: kvfree(relocs); err = -EFAULT; @@ -2991,7 +2991,8 @@ i915_gem_execbuffer2_ioctl(struct drm_device *dev, void *data, * And this range already got effectively checked earlier * when we did the "copy_from_user()" above. */ - if (!user_access_begin(user_exec_list, count * sizeof(*user_exec_list))) + if (!user_write_access_begin(user_exec_list, + count * sizeof(*user_exec_list))) goto end; for (i = 0; i < args->buffer_count; i++) { @@ -3005,7 +3006,7 @@ i915_gem_execbuffer2_ioctl(struct drm_device *dev, void *data, end_user); } end_user: - user_access_end(); + user_write_access_end(); end:; } -- 2.25.0