From: Eric Paris <eparis@redhat.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Possible memory leak via inotify_add_watch
Date: Mon, 06 Jul 2009 18:59:00 -0400 [thread overview]
Message-ID: <1246921140.2866.88.camel@dhcp235-23.rdu.redhat.com> (raw)
In-Reply-To: <b0943d9e0907061503r7a89a4e2lb5bc76b89e3e8ca6@mail.gmail.com>
On Mon, 2009-07-06 at 23:03 +0100, Catalin Marinas wrote:
> Hi Eric,
>
> I'm getting a few kmemleak reports like the one below (it may as well
> be just a false positive). All of these allocations happened during
> udevd.
Ok, I'll take a look. I know it highly unlikely but possible to leak in
sys_inotify_add_watch on some of the error paths. Seeing as how you
object has a mask it was at some point actually attached to an inode and
was removed. Since free_i_list is still unused that means it was
removed by an explicit request from inotify (inotify_rm_watch I guess),
not from the inode disappearing. I'll try to run it down exactly
tonight.
-Eric
> unreferenced object 0xc399fd80 (size 84):
> comm "udevd", pid 879, jiffies 4294897228
> backtrace:
> [<c01e0c3a>] create_object+0xfa/0x250
> [<c01e1e7d>] kmemleak_alloc+0x5d/0x70
> [<c01dac1b>] kmem_cache_alloc+0x14b/0x190
> [<c0213800>] sys_inotify_add_watch+0xc0/0x2a0
> [<c010300c>] sysenter_do_call+0x12/0x38
> [<ffffffff>] 0xffffffff
>
> Printing this object with gdb on /proc/kcore shows:
>
> (gdb) print {struct inotify_inode_mark_entry}0xc399fd80
> $2 = {fsn_entry = {mask = 134250504, refcnt = {counter = 1}, inode = 0x0,
> group = 0x0, i_list = {next = 0x0, pprev = 0x0}, g_list = {
> next = 0xc399fd98, prev = 0xc399fd98}, lock = {raw_lock = {
> slock = 1028}, magic = 3735899821, owner_cpu = 4294967295,
> owner = 0xffffffff, dep_map = {key = 0xc0d3e59c, class_cache = 0x0,
> name = 0xc068413d "&entry->lock"}}, free_i_list = {next = 0x6b6b6b6b,
> prev = 0x6b6b6b6b}, free_g_list = {next = 0x6b6b6b6b,
> prev = 0x6b6b6b6b}, free_mark = 0xc0213720 <inotify_free_mark>}, wd = 28}
>
> It seems that is was freed via fsnotify_destroy_mark_by_entry() since
> group and inode members are NULL and it was removed from any list. The
> fsn_entry.refcnt, however, is still 1. Kmemleak cannot find any
> pointer to this object (though it doesn't track alloc_pages memory
> blocks).
>
> Thanks.
>
next prev parent reply other threads:[~2009-07-06 22:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-06 22:03 Catalin Marinas
2009-07-06 22:59 ` Eric Paris [this message]
2009-07-07 2:09 ` Eric Paris
2009-07-07 13:03 ` Catalin Marinas
2009-07-07 13:11 ` Eric Paris
2009-07-07 16:24 ` Eric Paris
2009-07-07 21:30 ` Catalin Marinas
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=1246921140.2866.88.camel@dhcp235-23.rdu.redhat.com \
--to=eparis@redhat.com \
--cc=catalin.marinas@arm.com \
--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
all inboxes | Powered by JetHome®