All of lore.kernel.org
 help / color / mirror / Atom feed
* kmemleak not always catching stuff
@ 2017-09-01 22:33 Steven Rostedt
  2017-09-02 10:35 ` Dmitry Vyukov
  2017-09-04 10:09 ` Catalin Marinas
  0 siblings, 2 replies; 8+ messages in thread
From: Steven Rostedt @ 2017-09-01 22:33 UTC (permalink / raw)
  To: LKML; +Cc: Catalin Marinas, Andrey Ryabinin, kasan-dev

Hi,

Recently kmemleak discovered a bug in my code where an allocated
trampoline for a ftrace function tracer wasn't freed due to an exit
path. The thing is, kmemleak was able to catch this 100% when it was
triggered by one of my ftrace selftests that happen at bootup. But when
I trigger the issue from user space after bootup finished, it would not
catch it.

Now I was thinking that it may be due to the fact that the trampoline
is allocated with module_alloc(), and that has some magic kasan goo in
it. But when forcing the issue with adding the following code:

	void **pblah;
	void *blah;

	pblah = kmalloc(sizeof(*pblah), GFP_KERNEL);	
	blah = module_alloc(PAGE_SIZE);
	*pblah = blah;
	printk("allocated blah %p\n", blah);
	kfree(pblah);

in a path that I could control, it would catch it only after doing it
several times. I was never able to have kmemleak catch the actual bug
from user space no matter how many times I triggered it.

 # dmesg |grep kmemleak 
[   16.746832] kmemleak: Kernel memory leak detector initialized
[   16.746888] kmemleak: Automatic memory scanning thread started

And then I would do:

 # echo scan=on > /sys/kernel/debug/kmemleak

 [do the test]

 # echo scan > /sys/kernel/debug/kmemleak

Most of the times it found nothing. Even when I switched the above from
module_alloc() to kmalloc().

Is this normal?

-- Steve

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-09-08 18:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-01 22:33 kmemleak not always catching stuff Steven Rostedt
2017-09-02 10:35 ` Dmitry Vyukov
2017-09-04 10:09 ` Catalin Marinas
2017-09-05 14:15   ` Steven Rostedt
2017-09-08 17:45     ` Catalin Marinas
2017-09-08 18:34       ` Steven Rostedt
2017-09-05 14:23   ` Dmitry Vyukov
2017-09-05 14:39     ` Catalin Marinas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.