From: Peter Zijlstra <peterz@infradead.org>
To: Eric Paris <eparis@redhat.com>
Cc: linux-kernel@vger.kernel.org, viro@ZenIV.linux.org.uk
Subject: Re: [PATCH] inotify: inotify_destroy_mark_entry could get called twice
Date: Thu, 18 Jun 2009 13:25:18 +0200 [thread overview]
Message-ID: <1245324318.13761.23295.camel@twins> (raw)
In-Reply-To: <20090612202647.11976.87920.stgit@paris.rdu.redhat.com>
On Fri, 2009-06-12 at 16:26 -0400, Eric Paris wrote:
> inotify_destroy_mark_entry could get called twice for the same mark since it
> is called directly in inotify_rm_watch and when the mark is being destroyed for
> another reason. As an example assume that the file being watched was just
> deleted so inotify_destroy_mark_entry would get called from the path
> fsnotify_inoderemove() -> fsnotify_destroy_marks_by_inode() ->
> fsnotify_destroy_mark_entry() -> inotify_destroy_mark_entry(). If this
> happened at the same time as userspace tried to remove a watch via
> inotify_rm_watch we could attempt to remove the mark from the idr twice and
> could thus double dec the ref cnt and potentially could be in a use after
> free/double free situation. The fix is to have inotify_rm_watch use the
> generic recursive safe fsnotify_destroy_mark_by_entry() so we are sure the
> inotify_destroy_mark_entry() function can only be called one.
>
> This patch also renames the function to inotify_ingored_remove_idr() so it is
> clear what is actually going on in the function.
>
> Hopefully this fixes:
> [ 20.342058] idr_remove called for id=20 which is not allocated.
> [ 20.348000] Pid: 1860, comm: udevd Not tainted 2.6.30-tip #1077
> [ 20.353933] Call Trace:
> [ 20.356410] [<ffffffff811a82b7>] idr_remove+0x115/0x18f
> [ 20.361737] [<ffffffff8134259d>] ? _spin_lock+0x6d/0x75
> [ 20.367061] [<ffffffff8111640a>] ? inotify_destroy_mark_entry+0xa3/0xcf
> [ 20.373771] [<ffffffff8111641e>] inotify_destroy_mark_entry+0xb7/0xcf
> [ 20.380306] [<ffffffff81115913>] inotify_freeing_mark+0xe/0x10
> [ 20.386238] [<ffffffff8111410d>] fsnotify_destroy_mark_by_entry+0x143/0x170
> [ 20.393293] [<ffffffff811163a3>] inotify_destroy_mark_entry+0x3c/0xcf
> [ 20.399829] [<ffffffff811164d1>] sys_inotify_rm_watch+0x9b/0xc6
> [ 20.405850] [<ffffffff8100bcdb>] system_call_fastpath+0x16/0x1b
>
> Reported-by: Peter Zijlstra <peterz@infradead.org>
Tested-by: Peter Zijlstra <peterz@infradead.org>
Thanks Eric!!
prev parent reply other threads:[~2009-06-18 11:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-12 20:26 Eric Paris
2009-06-18 11:25 ` Peter Zijlstra [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=1245324318.13761.23295.camel@twins \
--to=peterz@infradead.org \
--cc=eparis@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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®