Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Rob Clark <robdclark@gmail.com>
Cc: linux-arm-msm <linux-arm-msm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Julia Lawall <julia.lawall@lip6.fr>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Vaishali Thakkar <vaishali.thakkar@oracle.com>,
	freedreno@lists.freedesktop.org
Subject: Re: Use of copy_from_user in msm_gem_submit.c while holding a spin_lock
Date: Thu, 18 Aug 2016 15:08:45 +0200	[thread overview]
Message-ID: <20160818130845.GB6232@phenom.ffwll.local> (raw)
In-Reply-To: <CAF6AEGuUWGjXaACzi4D2AeSEHzy5dxV6aQSqMFf6Bc0e3+XXuA@mail.gmail.com>

On Thu, Aug 18, 2016 at 06:55:12AM -0400, Rob Clark wrote:
> On Thu, Aug 18, 2016 at 4:36 AM, Daniel Vetter <daniel@ffwll.ch> 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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2016-08-18 13:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-17 11:40 Use of copy_from_user in msm_gem_submit.c while holding a spin_lock Vaishali Thakkar
     [not found] ` <57B44D2E.2030301-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-08-17 15:08   ` Rob Clark
2016-08-17 17:08     ` Al Viro
     [not found]       ` <20160817170827.GC2356-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2016-08-17 18:49         ` Rob Clark
     [not found]           ` <CAF6AEGtLVW-_PMhpb5YQX_vXfn5t=jH7Fe7R+1DbMaoWt6Cc1A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-17 18:58             ` Rob Clark
2016-08-17 19:15             ` Al Viro
2016-08-17 19:24               ` Rob Clark
2016-08-17 19:31                 ` Al Viro
2016-08-18  8:31                   ` Daniel Vetter
2016-08-17 21:29               ` Rob Clark
     [not found]                 ` <CAF6AEGsJ0scrJp_4Udh2PTxwZq6_poRZuDQYHF6UayFb1htT5Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-18  8:36                   ` Daniel Vetter
2016-08-18 10:55                     ` Rob Clark
2016-08-18 13:08                       ` Daniel Vetter [this message]
2016-08-18 13:14                         ` Rob Clark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160818130845.GB6232@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robdclark@gmail.com \
    --cc=vaishali.thakkar@oracle.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox