From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1947182AbcHRNIx (ORCPT ); Thu, 18 Aug 2016 09:08:53 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35711 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946379AbcHRNIu (ORCPT ); Thu, 18 Aug 2016 09:08:50 -0400 Date: Thu, 18 Aug 2016 15:08:45 +0200 From: Daniel Vetter To: Rob Clark Cc: Al Viro , Vaishali Thakkar , David Airlie , linux-arm-msm , "dri-devel@lists.freedesktop.org" , freedreno@lists.freedesktop.org, Linux Kernel Mailing List , Julia Lawall , Daniel Vetter Subject: Re: Use of copy_from_user in msm_gem_submit.c while holding a spin_lock Message-ID: <20160818130845.GB6232@phenom.ffwll.local> Mail-Followup-To: Rob Clark , Al Viro , Vaishali Thakkar , David Airlie , linux-arm-msm , "dri-devel@lists.freedesktop.org" , freedreno@lists.freedesktop.org, Linux Kernel Mailing List , Julia Lawall References: <57B44D2E.2030301@oracle.com> <20160817170827.GC2356@ZenIV.linux.org.uk> <20160817191534.GF2356@ZenIV.linux.org.uk> <20160818083651.GY6232@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 4.6.0-1-amd64 User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 18, 2016 at 06:55:12AM -0400, Rob Clark wrote: > On Thu, Aug 18, 2016 at 4:36 AM, Daniel Vetter wrote: > > On Wed, Aug 17, 2016 at 05:29:31PM -0400, Rob Clark wrote: > >> diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c > >> index 6cd4af4..4502e4b 100644 > >> --- a/drivers/gpu/drm/msm/msm_gem.c > >> +++ b/drivers/gpu/drm/msm/msm_gem.c > >> @@ -201,6 +201,13 @@ int msm_gem_fault(struct vm_area_struct *vma, > >> struct vm_fault *vmf) > >> pgoff_t pgoff; > >> int ret; > >> > >> + /* I think this should only happen if userspace tries to pass a > >> + * mmap'd but unfaulted gem bo vaddr into submit ioctl, triggering > >> + * a page fault while struct_mutex is already held > >> + */ > >> + if (mutex_is_locked_by(&dev->struct_mutex, current)) > >> + return VM_FAULT_SIGBUS; > > > > This is an ok (well still horrible) heuristics for the shrinker, but for > > correctness it kinda doesn't cut it. What you need to do instead is drop > > all the locks, copy relocations into a temp memory area and then proceed > > in the msm command submission path above. > > > > Also reentrant mutexes are evil ;-) > > Please note that this is not a reentrant mutex in the fault path, it > bails with VM_FAULT_SIGBUG! Except on UP it totally deadlocks ;-) -Daniel > There is never a legit reason to use a gem bo for the bos (or cmds) > table in the ioctl, so while this may not be pretty, I believe it is > an acceptable solution. -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch