public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Sherry Yang <sherryy@android.com>
Cc: linux-kernel@vger.kernel.org,
	"open list:ANDROID DRIVERS" <devel@driverdev.osuosl.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Riley Andrews" <riandrews@android.com>,
	maco@google.com, tkjos@google.com
Subject: Re: [PATCH v2 3/5] android: binder: Move buffer out of area shared with user space
Date: Thu, 24 Aug 2017 23:29:44 +0300	[thread overview]
Message-ID: <20170824202943.5euttnd7hlbdpyj2@mwanda> (raw)
In-Reply-To: <20170823154643.2613-4-sherryy@android.com>

On Wed, Aug 23, 2017 at 08:46:41AM -0700, Sherry Yang wrote:
> Binder driver allocates buffer meta data in a region that is mapped
> in user space. These meta data contain pointers in the kernel.
> 
> This patch allocates buffer meta data on the kernel heap that is
> not mapped in user space, and uses a pointer to refer to the data mapped.
> 

This feels like it has a security impact, right?  The original code is
an info leak?

> @@ -664,7 +679,7 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
>  
>  	return 0;
>  
> -err_alloc_small_buf_failed:
> +err_alloc_buf_struct_failed:
>  	kfree(alloc->pages);
>  	alloc->pages = NULL;
>  err_alloc_pages_failed:

Not really really related to your patch, I was just looking at the
error handling here.  It looks like this with your patch applied.

   682  err_alloc_buf_struct_failed:
   683          kfree(alloc->pages);
   684          alloc->pages = NULL;
   685  err_alloc_pages_failed:
   686          mutex_lock(&binder_alloc_mmap_lock);
   687          vfree(alloc->buffer);

The vfree() here is supposed to release the resources from get_vm_area().
Why do people not use free_vm_area() instead?  It feels like we're
freeing "area->addr" but leaking "area" itself but perhaps I have
misunderstood something.

   688          alloc->buffer = NULL;
   689  err_get_vm_area_failed:
   690  err_already_mapped:
   691          mutex_unlock(&binder_alloc_mmap_lock);
   692          pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
   693                 alloc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
   694          return ret;

regards,
dan carpenter

  reply	other threads:[~2017-08-24 20:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-23 15:46 [PATCH v2 0/5] android: binder: move allocator metadata and add shrinker Sherry Yang
2017-08-23 15:46 ` [PATCH v2 1/5] android: binder: Refactor prev and next buffer into a helper function Sherry Yang
2017-08-23 23:18   ` Greg Kroah-Hartman
2017-08-23 15:46 ` [PATCH v2 2/5] android: binder: Add allocator selftest Sherry Yang
2017-08-23 15:46 ` [PATCH v2 3/5] android: binder: Move buffer out of area shared with user space Sherry Yang
2017-08-24 20:29   ` Dan Carpenter [this message]
2017-08-23 15:46 ` [PATCH v2 4/5] android: binder: Add global lru shrinker to binder Sherry Yang
2017-08-23 15:46 ` [PATCH v2 5/5] android: binder: Add shrinker tracepoints Sherry Yang

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=20170824202943.5euttnd7hlbdpyj2@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=arve@android.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maco@google.com \
    --cc=riandrews@android.com \
    --cc=sherryy@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