[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20190305193507.GA149288@google.com>
Date: Tue, 5 Mar 2019 14:35:07 -0500
From: Joel Fernandes <joel@...lfernandes.org>
To: Todd Kjos <tkjos@...gle.com>
Cc: Greg KH <gregkh@...uxfoundation.org>,
Todd Kjos <tkjos@...roid.com>,
Arve Hjønnevåg <arve@...roid.com>,
"open list:ANDROID DRIVERS" <devel@...verdev.osuosl.org>,
LKML <linux-kernel@...r.kernel.org>,
Martijn Coenen <maco@...gle.com>,
Android Kernel Team <kernel-team@...roid.com>
Subject: Re: [PATCH] binder: fix race between munmap() and direct reclaim
On Sat, Mar 02, 2019 at 08:27:44AM -0800, Todd Kjos wrote:
> On Fri, Mar 1, 2019 at 11:57 PM Greg KH <gregkh@...uxfoundation.org> wrote:
> >
> > On Fri, Mar 01, 2019 at 03:06:06PM -0800, Todd Kjos wrote:
> > > An munmap() on a binder device causes binder_vma_close() to be called
> > > which clears the alloc->vma pointer.
> > >
> > > If direct reclaim causes binder_alloc_free_page() to be called, there
> > > is a race where alloc->vma is read into a local vma pointer and then
> > > used later after the mm->mmap_sem is acquired. This can result in
> > > calling zap_page_range() with an invalid vma which manifests as a
> > > use-after-free in zap_page_range().
> > >
> > > The fix is to check alloc->vma after acquiring the mmap_sem (which we
> > > were acquiring anyway) and skip zap_page_range() if it has changed
> > > to NULL.
> > >
> > > Signed-off-by: Todd Kjos <tkjos@...gle.com>
Awesome patch,
Reviewed-by: Joel Fernandes (Google) <joel@...lfernandes.org>
thanks!
- Joel
> > > ---
> >
> > Any specific commit that this fixes?
>
> No, it's been there a long time.
>
> > And should it be marked for stable releases?
>
> It is needed in stable (back to 4.4), but will need to be backported.
> Should I post backported versions targeting the specific releases now?
> I was thinking we'd wait for this one to land. I think we'll need 1
> patch for 4.4/4.9 and a second one for 4.14/4.19 (and some of those
> backported patches will have conflicts when merged down to android-4.X
> -- I think the 4.14/4.19 version will apply to all the android
> branches). Let me know how you want to handle this.
>
> >
> > thanks,
> >
> > greg k-h
Powered by blists - more mailing lists