From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D614CC43331 for ; Thu, 2 Apr 2020 07:52:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 94A972063A for ; Thu, 2 Apr 2020 07:52:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="A6ZJzATV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94A972063A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 45BEB8E0009; Thu, 2 Apr 2020 03:52:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4332A8E0007; Thu, 2 Apr 2020 03:52:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 348998E0009; Thu, 2 Apr 2020 03:52:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 18E878E0007 for ; Thu, 2 Apr 2020 03:52:19 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D8D28181AC9CC for ; Thu, 2 Apr 2020 07:52:18 +0000 (UTC) X-FDA: 76662147156.03.blood08_88942116cb940 X-HE-Tag: blood08_88942116cb940 X-Filterd-Recvd-Size: 5510 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Thu, 2 Apr 2020 07:52:18 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id d17so1493906pgo.0 for ; Thu, 02 Apr 2020 00:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=YDhcDFzxnB0LzwhhhavzuQofpQqoxKbtsiZ2UHnUGxU=; b=A6ZJzATVZMdYm6aYjzbAsFnbVu+/ukE/HUOrWoX6wNSXH7TjId503hbalZIcER3qhr Y5qB/1CFmXiQvAttlkjKxpgOTqSerdCjb/TPzMe6QvKL8r5gTbbRJSL4V6e2L7JhAA5B DOCsSudHTl/uKCgBkojQz+0LCaSqXe0yQNm4M= 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:references :mime-version:content-disposition:in-reply-to; bh=YDhcDFzxnB0LzwhhhavzuQofpQqoxKbtsiZ2UHnUGxU=; b=aWVy1sqwogVWnc72rBTBgur2gHt9msMWH34s2tkGQiCP3hAnvd5va2Ie4YgBk6YngP FXcCI4aZCdHEFJBXTF7ZgQ1chzxxBfxk1AP71qYDG/8kzJMxWLWcZUSxfBjjDiw9+Xzr maxiabrblBHwyoYyenQK75/u4nZN1TF7Qv68UoWyCfbAwJzL/XT8mrbxRReqXnegtSus Z9I55F7aes2q+jmNZ+roHAkHzU6qglJfbIJUnHpYPpoI++XDFWszK5CXzm8C3aHOcUDp 6MYQMPMO9BgSGXdd5jBwIL6awHgmfWZ6d8CIzjXh03YS561tC3tBk3C2asG7pV0FTLkX j0Bg== X-Gm-Message-State: AGi0PuaFowLc7FQ76PpwU0Gdj5g/rgnHUi8aqXtDMeFbMYbJhje0OYFW ULWdQqmRiYv3rXGVfoBYu2fRVw== X-Google-Smtp-Source: APiQypKB4nOuEy27sAy36sblXB+uB0SHnxgxvV5A0l19f7PmP5vbDtzIT9/IOshcLycLAXLiPPMwyg== X-Received: by 2002:a63:8c13:: with SMTP id m19mr2113657pgd.44.1585813937373; Thu, 02 Apr 2020 00:52:17 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id m14sm3216861pje.19.2020.04.02.00.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 00:52:16 -0700 (PDT) Date: Thu, 2 Apr 2020 00:52:15 -0700 From: Kees Cook To: Christophe Leroy Cc: 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, hpa@zytor.com, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-arch@vger.kernel.org Subject: Re: [PATCH RESEND 3/4] drm/i915/gem: Replace user_access_begin by user_write_access_begin Message-ID: <202004020051.649C6B8@keescook> References: <27106d62fdbd4ffb47796236050e418131cb837f.1585811416.git.christophe.leroy@c-s.fr> <6da6fa391c0d6344cc9ff99a69fcaa65666f3947.1585811416.git.christophe.leroy@c-s.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6da6fa391c0d6344cc9ff99a69fcaa65666f3947.1585811416.git.christophe.leroy@c-s.fr> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Apr 02, 2020 at 07:34:18AM +0000, Christophe Leroy wrote: > 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 Why is this split from the other conversions? Reviewed-by: Kees Cook > --- > 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 > -- Kees Cook