From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Greg Hackmann <ghackmann@android.com>
Cc: linux-kernel@vger.kernel.org, Laura Abbott <labbott@redhat.com>,
Sumit Semwal <sumit.semwal@linaro.org>,
devel@driverdev.osuosl.org, kernel-team@android.com,
Greg Hackmann <ghackmann@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] staging: android: ion: fix ION_IOC_{MAP,SHARE} use-after-free
Date: Fri, 31 Aug 2018 13:12:32 -0700 [thread overview]
Message-ID: <20180831201232.GA23559@kroah.com> (raw)
In-Reply-To: <20180831200627.59712-1-ghackmann@google.com>
On Fri, Aug 31, 2018 at 01:06:27PM -0700, Greg Hackmann wrote:
> The ION_IOC_{MAP,SHARE} ioctls drop and reacquire client->lock several
> times while operating on one of the client's ion_handles. This creates
> windows where userspace can call ION_IOC_FREE on the same client with
> the same handle, and effectively make the kernel drop its own reference.
> For example:
>
> - thread A: ION_IOC_ALLOC creates an ion_handle with refcount 1
> - thread A: starts ION_IOC_MAP and increments the refcount to 2
> - thread B: ION_IOC_FREE decrements the refcount to 1
> - thread B: ION_IOC_FREE decrements the refcount to 0 and frees the
> handle
> - thread A: continues ION_IOC_MAP with a dangling ion_handle * to
> freed memory
>
> Fix this by holding client->lock for the duration of
> ION_IOC_{MAP,SHARE}, preventing the concurrent ION_IOC_FREE. Also
> remove ion_handle_get_by_id(), since there's literally no way to use it
> safely.
>
> This patch is applied on top of 4.9.y. Kernels 4.12 and later are
> unaffected, since all the underlying ion_handle infrastructure has been
> ripped out.
Does 4.4.y or older also need this? If so, can you send backports, as
this one does not apply there.
thanks,
greg k-h
next prev parent reply other threads:[~2018-09-01 0:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-31 20:06 [PATCH] staging: android: ion: fix ION_IOC_{MAP,SHARE} use-after-free Greg Hackmann
2018-08-31 20:12 ` Greg Kroah-Hartman [this message]
2018-08-31 20:17 ` Greg Hackmann
2018-08-31 20:22 ` Greg Kroah-Hartman
2018-08-31 20:27 ` Greg Hackmann
2018-08-31 20:30 ` Greg Hackmann
2018-09-01 21:38 ` Greg Kroah-Hartman
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=20180831201232.GA23559@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=devel@driverdev.osuosl.org \
--cc=ghackmann@android.com \
--cc=ghackmann@google.com \
--cc=kernel-team@android.com \
--cc=labbott@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
/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).