* Inotify memory leak
@ 2010-11-23 23:15 Vegard Nossum
2010-11-23 23:25 ` Eric Paris
0 siblings, 1 reply; 2+ messages in thread
From: Vegard Nossum @ 2010-11-23 23:15 UTC (permalink / raw)
To: Eric Paris, Al Viro; +Cc: LKML, Eugene Teo
Hi,
Inotify does not clean up properly when it fails to create the file
descriptor. So it leaks kernel memory. Watch "slabtop" while running
this program:
#include <sys/inotify.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int fds[2];
/* Circumvent max inotify instances limit */
while (pipe(fds) != -1)
;
while (1)
inotify_init();
return 0;
}
Specifically, the problem is in inotify_init1 where the group pointer is leaked:
group = inotify_new_group(user, inotify_max_queued_events);
[...]
ret = anon_inode_getfd("inotify", &inotify_fops, group,
O_RDONLY | flags);
if (ret >= 0)
return ret;
atomic_dec(&user->inotify_devs);
out_free_uid:
free_uid(user);
return ret;
I think it should be easily fixed by calling fsnotify_put_group() at
the right place.
Vegard
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Inotify memory leak
2010-11-23 23:15 Inotify memory leak Vegard Nossum
@ 2010-11-23 23:25 ` Eric Paris
0 siblings, 0 replies; 2+ messages in thread
From: Eric Paris @ 2010-11-23 23:25 UTC (permalink / raw)
To: Vegard Nossum; +Cc: Al Viro, LKML, Eugene Teo
On Wed, 2010-11-24 at 00:15 +0100, Vegard Nossum wrote:
> Hi,
>
> Inotify does not clean up properly when it fails to create the file
> descriptor. So it leaks kernel memory. Watch "slabtop" while running
> this program:
>
> #include <sys/inotify.h>
> #include <unistd.h>
potential patch at
http://git.infradead.org/users/eparis/notify.git/shortlog/refs/heads/for-next
Only compiled, not tested. Will try to do that after dinner!
-Eric
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-23 23:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-23 23:15 Inotify memory leak Vegard Nossum
2010-11-23 23:25 ` Eric Paris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome