stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Todd Kjos <tkjos@android.com>
Cc: tkjos@google.com, arve@android.com, stable@vger.kernel.org,
	maco@google.com, joel@joelfernandes.org, kernel-team@android.com
Subject: Re: [PATCH stable] binder: fix race between munmap() and direct reclaim
Date: Mon, 29 Apr 2019 14:00:02 +0200	[thread overview]
Message-ID: <20190429120002.GA19611@kroah.com> (raw)
In-Reply-To: <20190424173556.85545-1-tkjos@google.com>

On Wed, Apr 24, 2019 at 10:35:56AM -0700, Todd Kjos wrote:
> From: Todd Kjos <tkjos@android.com>
> 
> commit 5cec2d2e5839f9c0fec319c523a911e0a7fd299f upstream.
> 
> 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>
> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> Cc: stable <stable@vger.kernel.org> # 5.0, 4.19, 4.14
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> Greg: This applies to 5.0, 4.19, 4.14. Not needed before 4.12.

Thanks, now queued up.

greg k-h

      reply	other threads:[~2019-04-29 12:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24 17:35 [PATCH stable] binder: fix race between munmap() and direct reclaim Todd Kjos
2019-04-29 12:00 ` Greg KH [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=20190429120002.GA19611@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=arve@android.com \
    --cc=joel@joelfernandes.org \
    --cc=kernel-team@android.com \
    --cc=maco@google.com \
    --cc=stable@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).