From: Joel Fernandes <joel@joelfernandes.org>
To: Daniel Colascione <dancol@google.com>
Cc: "Alistair Strachan" <astrachan@google.com>,
linux-kernel@vger.kernel.org,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Martijn Coenen" <maco@android.com>,
devel@driverdev.osuosl.org, kernel-team@android.com
Subject: Re: [PATCH 2/2 v2] staging: android: ashmem: Fix mmap size validation
Date: Wed, 20 Jun 2018 16:29:37 -0700 [thread overview]
Message-ID: <20180620232937.GA177510@joelaf.mtv.corp.google.com> (raw)
In-Reply-To: <CAKOZuetoYikhAz1c6NuaVjeU_E58hbH7wMsDUKCYWqb63ESPeA@mail.gmail.com>
On Wed, Jun 20, 2018 at 02:21:57PM -0700, Daniel Colascione wrote:
> On Tue, Jun 19, 2018 at 9:32 PM, Joel Fernandes <joel@joelfernandes.org> wrote:
> > On Tue, Jun 19, 2018 at 05:57:35PM -0700, Alistair Strachan wrote:
> > > The ashmem driver did not check that the size/offset of the vma passed
> > > to its .mmap() function was not larger than the ashmem object being
> > > mapped. This could cause mmap() to succeed, even though accessing parts
> > > of the mapping would later fail with a segmentation fault.
> > >
> > > Ensure an error is returned by the ashmem_mmap() function if the vma
> > > size is larger than the ashmem object size. This enables safer handling
> > > of the problem in userspace.
>
> Are we sure that this approach is a good idea? You can over-mmap
> regular files. I don't like the idea of creating special mmap
ashmem isn't a regular file.
> semantics for files that happen to be ashmem files. Ashmem users can
> detect size-changing shenanigans with ASHMEM_GET_SIZE after mmap,
> since an ashmem file's size can't change after an mmap call succeeds.
But it is misleading to allow it. If the mmap succeeds, the any writes to the
extra area is infact not a part of ashmem and will not be shared. Instead if
the mmap fails up front, then we're telling the user upfront that they
screwed up and they should do something about it. I would much rather have
the mmap fail than to allow for other issues to later occur.
Also if you look at the kernel sources, there are dozens of drivers that
check for correct VMA size in mmap handler and fail if it isn't sized
correctly.
thanks!
- Joel
next prev parent reply other threads:[~2018-06-20 23:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-20 0:57 [PATCH 1/2] staging: android: ashmem: Remove use of unlikely() Alistair Strachan
2018-06-20 0:57 ` [PATCH 2/2 v2] staging: android: ashmem: Fix mmap size validation Alistair Strachan
2018-06-20 4:32 ` Joel Fernandes
2018-06-20 21:21 ` Daniel Colascione
2018-06-20 23:29 ` Joel Fernandes [this message]
2018-06-22 8:48 ` Martijn Coenen
2018-06-20 4:32 ` [PATCH 1/2] staging: android: ashmem: Remove use of unlikely() Joel Fernandes
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=20180620232937.GA177510@joelaf.mtv.corp.google.com \
--to=joel@joelfernandes.org \
--cc=arve@android.com \
--cc=astrachan@google.com \
--cc=dancol@google.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maco@android.com \
--cc=tkjos@android.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
all inboxes | Powered by JetHome®