public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joel Fernandes <joel@joelfernandes.org>
To: Todd Kjos <tkjos@google.com>
Cc: "Greg KH" <gregkh@linuxfoundation.org>,
	"Todd Kjos" <tkjos@android.com>,
	"Arve Hjønnevåg" <arve@android.com>,
	"open list:ANDROID DRIVERS" <devel@driverdev.osuosl.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Martijn Coenen" <maco@google.com>,
	"Android Kernel Team" <kernel-team@android.com>
Subject: Re: [PATCH] binder: fix race between munmap() and direct reclaim
Date: Tue, 5 Mar 2019 14:35:07 -0500	[thread overview]
Message-ID: <20190305193507.GA149288@google.com> (raw)
In-Reply-To: <CAHRSSExy=kWt+MDzD10VogfasygJET6FmEtRc9vJuLv4Ov7+uA@mail.gmail.com>

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@linuxfoundation.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@google.com>

Awesome patch, 
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.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

      reply	other threads:[~2019-03-05 19:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-01 23:06 [PATCH] binder: fix race between munmap() and direct reclaim Todd Kjos
2019-03-02  7:57 ` Greg KH
2019-03-02 16:27   ` Todd Kjos
2019-03-05 19:35     ` Joel Fernandes [this message]

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=20190305193507.GA149288@google.com \
    --to=joel@joelfernandes.org \
    --cc=arve@android.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maco@google.com \
    --cc=tkjos@android.com \
    --cc=tkjos@google.com \
    /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