linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Paris <eparis@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] inotify: race use after free/double free in inotify inode marks
Date: Thu, 13 May 2010 07:31:48 -0400	[thread overview]
Message-ID: <1273750308.2772.18.camel@localhost> (raw)
In-Reply-To: <20100512201631.a6955325.akpm@linux-foundation.org>

On Wed, 2010-05-12 at 20:16 -0400, Andrew Morton wrote:
> On Wed, 12 May 2010 12:08:00 -0400 Eric Paris <eparis@redhat.com> wrote:
> 
> > From: root <root@tyan-gt24-04.rhts.eng.bos.redhat.com>
> 
> hm.

Well poop.  That's what I get for using git on a random test box.  I
moved it to my real tree with git-format-patch > git-am.  I'll fix the
author.

> > There is a race in the inotify add/rm watch code.  A task can find and
> > remove a mark which doesn't have all of it's references.  This can
> > result in a use after free/double free situation.
> > 
> > Task A					Task B
> > ------------				-----------
> > inotify_new_watch()
> >  allocate a mark (refcnt == 1)
> >  add it to the idr
> > 					inotify_rm_watch()
> > 					 inotify_remove_from_idr()
> > 					  fsnotify_put_mark()
> > 					      refcnt hits 0, free
> >  take reference because we are on idr
> >  [at this point it is a use after free]
> >  [time goes on]
> >  refcnt may hit 0 again, double free
> > 
> > The fix is to take the reference BEFORE the object can be found in the
> > idr.
> > 
> > Signed-off-by: Eric Paris <eparis@redhat.com>
> 
> The changelog has no "Cc: <stable@kernel.org>".  I suspect it should
> have that?

Will fix before I ask Linus to pull....

-Eric


      reply	other threads:[~2010-05-13 11:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-12 16:08 [PATCH] inotify: race use after free/double free in inotify inode marks Eric Paris
2010-05-13  0:16 ` Andrew Morton
2010-05-13 11:31   ` Eric Paris [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=1273750308.2772.18.camel@localhost \
    --to=eparis@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).