CEPH filesystem development
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: ceph-devel@vger.kernel.org
Subject: Re: [PATCH] ceph: fix potential double free
Date: Fri, 13 Jul 2012 11:53:48 -0500	[thread overview]
Message-ID: <5000529C.50202@inktank.com> (raw)
In-Reply-To: <20120713173722.1786d02f@pyramind.ukuu.org.uk>

On 07/13/2012 11:37 AM, Alan Cox wrote:
>> Is that clear?  Is there something I'm still missing?
> 
> Basically if they are not invariant I don't see why it can't go around
> the loop, allocate the buffer, free it and then the next time find there
> is nothing there and thus double free.
> 
> Either way if its patched the problem goes away so it's mostly for my own
> understanding.

The key is that xattrs is a local variable I think.

1)  enter the "if" block
2)  spin_unlock()
3)  xattrs = kcalloc()...
4)  spin_lock()
5)  version changes, so:
6)    kfree everything (now xattrs is invalid)
7)    goto start

Then either:
8a) re-enter the "if" block
9a) spin_unlock()
10a) xattrs = kcalloc()... <- now xattrs is valid again
. . .

Or:
8b)  do not enter the "if" block
9b)  return err... <- xattrs is not referenced again

					-Alex



      reply	other threads:[~2012-07-13 16:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-13 14:28 [PATCH] ceph: fix potential double free Alan Cox
2012-07-13 14:36 ` Alex Elder
2012-07-13 14:56   ` Alan Cox
2012-07-13 15:39     ` Alex Elder
2012-07-13 16:37       ` Alan Cox
2012-07-13 16:53         ` Alex Elder [this message]

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=5000529C.50202@inktank.com \
    --to=elder@inktank.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=ceph-devel@vger.kernel.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