All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Todd Kjos <tkjos@android.com>
Cc: tkjos@google.com, arve@android.com, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, maco@google.com
Subject: Re: [PATCH v2] binder: fix proc->files use-after-free
Date: Thu, 16 Nov 2017 21:27:06 +0100	[thread overview]
Message-ID: <20171116202706.GA10790@kroah.com> (raw)
In-Reply-To: <20171116175650.40362-1-tkjos@google.com>

On Thu, Nov 16, 2017 at 09:56:50AM -0800, Todd Kjos wrote:
> proc->files cleanup is initiated by binder_vma_close. Therefore
> a reference on the binder_proc is not enough to prevent the
> files_struct from being released while the binder_proc still has
> a reference. This can lead to an attempt to dereference the
> stale pointer obtained from proc->files prior to proc->files
> cleanup. This has been seen once in task_get_unused_fd_flags()
> when __alloc_fd() is called with a stale "files".
> 
> The fix is to always use get_files_struct() to obtain struct_files
> so that the refcount on the files_struct is used to prevent
> a premature free. proc->files is removed since we get it every
> time.
> 
> Signed-off-by: Todd Kjos <tkjos@google.com>
> ---
>  drivers/android/binder.c | 63 +++++++++++++++++++++++-------------------------
>  1 file changed, 30 insertions(+), 33 deletions(-)

For a v2 patch (or v3 or whatever), you need to put below the --- line
what changed from the previous version(s).
Documentation/SubmittingPatches describes this pretty well :)

thanks,

greg k-h

  reply	other threads:[~2017-11-16 20:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-16 17:56 [PATCH v2] binder: fix proc->files use-after-free Todd Kjos
2017-11-16 20:27 ` Greg KH [this message]
2017-11-16 20:37   ` Todd Kjos
2017-11-17  9:30     ` Greg KH
2017-11-17 19:31 ` Al Viro
2017-11-20 16:57   ` Todd Kjos

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=20171116202706.GA10790@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=arve@android.com \
    --cc=devel@driverdev.osuosl.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.