All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: JoonSoo Kim <js1304@gmail.com>
Cc: devel@driverdev.osuosl.org, "Robert Love" <rlove@google.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Colin Cross" <ccross@android.com>,
	linux-kernel@vger.kernel.org, "Dima Zavin" <dima@android.com>,
	"Arve Hjønnevåg" <arve@android.com>,
	"John Stultz" <john.stultz@linaro.org>,
	"Brian Swetland" <swetland@google.com>,
	"Android Kernel Team" <kernel-team@android.com>
Subject: Re: [RFC PATCH] staging, android, ashmem: invalidate pin/unpin ioctl for private map
Date: Mon, 3 Dec 2012 10:31:09 +0300	[thread overview]
Message-ID: <20121203073109.GD6568@mwanda> (raw)
In-Reply-To: <CAAmzW4NM5prCnVeaGXGzkvZzg=oQMMC2oKpjEcXuDgfebZe_Pw@mail.gmail.com>

On Mon, Dec 03, 2012 at 09:09:59AM +0900, JoonSoo Kim wrote:
> Hello, Dan.
> 
> 2012/12/2 Dan Carpenter <dan.carpenter@oracle.com>:
> > On Sat, Dec 01, 2012 at 02:45:57AM +0900, Joonsoo Kim wrote:
> >> @@ -614,21 +616,35 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd,
> >>       pgstart = pin.offset / PAGE_SIZE;
> >>       pgend = pgstart + (pin.len / PAGE_SIZE) - 1;
> >>
> >> -     mutex_lock(&ashmem_mutex);
> >> +     if (asma->shared_mapping) {
> >> +             mutex_lock(&ashmem_mutex);
> >
> > Wouldn't we need to hold the mutex while we check the
> > ->shared_mapping?
> 
> I doesn't fully understand ashmem's lock semantic.
> Code for retrieving some value of asma instance doesn't hold the mutex, now.
> For example, in ashmem_ioctl(), asma->size, asma->prot_mask.
> And in ashmem_pin_unpin(), there is asma->file, asma->size which is
> retrieved without the mutex.
> According to this semantic, the mutex doesn't need for checking
> asma->shared_mapping.

The ashmem_ioctl() is clearly racy.  :P  asma->size can be modified
and read at the same time.  It's not an example to follow.

regards,
dan carpenter


  reply	other threads:[~2012-12-03  7:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-30 17:45 [RFC PATCH] staging, android, ashmem: invalidate pin/unpin ioctl for private map Joonsoo Kim
2012-12-01 18:39 ` Dan Carpenter
2012-12-03  0:09   ` JoonSoo Kim
2012-12-03  7:31     ` Dan Carpenter [this message]
2012-12-03 14:52       ` JoonSoo Kim

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=20121203073109.GD6568@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=arve@android.com \
    --cc=ccross@android.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=dima@android.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=john.stultz@linaro.org \
    --cc=js1304@gmail.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rlove@google.com \
    --cc=swetland@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.