nitturis-linux / kedr

Automatically exported from code.google.com/p/kedr
0 stars 1 forks source link

allocations via kzalloc_node() are not properly tracked #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I don't have a more recent system handy to test, but on my CentOS 6.3 
2.6.32-358.23.2.el6.x86_64 system I observed the following behaviour with the 
leak checker:

'Unallocated frees' were reported on memory allocated by kzalloc_node() which 
had matching calls to kfree().  Likewise the 'Allocations' were reported as 
being much lower.  Changing all allocations to kzalloc() instead resolved all 
counts.

-Brett Ciphery

Original issue reported on code.google.com by bciph...@gmail.com on 12 Aug 2014 at 1:44

GoogleCodeExporter commented 9 years ago
Tried kedr-0.5.tar.bz2 as well as hg checkout as of August 11, 2014.

Original comment by bciph...@gmail.com on 12 Aug 2014 at 1:58

GoogleCodeExporter commented 9 years ago
Hm, kzalloc_node() is usually a wrapper around 
kmalloc_node/__kmalloc_node/kmem_cache_alloc_node_notrace/kmem_cache_alloc_node 
all of which should be handled. May be some particular case is missing. I'll 
take a look.

Please post the following info here:
# The output of cmake when you configure KEDR (it shows which functions KEDR 
will be able to handle on the current kernel).
# The output of `readelf -sW <.ko_file_of_your_module>  | grep UND | less` 
(when your module uses kzalloc_node). This will show which kernel functions 
your module imports.

Original comment by euspec...@gmail.com on 13 Aug 2014 at 7:11

GoogleCodeExporter commented 9 years ago
... without '| less', of course.

Original comment by euspec...@gmail.com on 13 Aug 2014 at 7:12

GoogleCodeExporter commented 9 years ago
Attached -- much appreciated.

You mentioned kmem_cache_alloc_node_notrace but I do see that it's importing 
kmem_cache_alloc_node_trace, which KEDR configuration couldn't find.

Original comment by bciph...@gmail.com on 13 Aug 2014 at 1:55

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the info. Yes, you are right, this must be it.

I reproduced the problem on my CentOS 6 box. Working on a fix...

Original comment by euspec...@gmail.com on 18 Aug 2014 at 4:29

GoogleCodeExporter commented 9 years ago
I think I got it. 

'#include <linux/version.h>' was missing from 
'sources/cmake/kmodule_sources/check_unreliable_functions/kmem_cache_alloc_node_
trace.c', which is used to check if the function is present. It failed and KEDR 
assumed 'kmem_cache_alloc_node_trace' is not available. Other systems I tested 
might have #included that header via others so the problem went unnoticed.

I fixed that in the repository: 
http://code.google.com/p/kedr/source/detail?r=8760efeaec94888e6b85a88a8c76901a7d
102607

Please try the latest revision from there or add '#include <linux/version.h>' 
to that file manually and check if everything works OK on your system too.

Original comment by euspec...@gmail.com on 18 Aug 2014 at 5:43

GoogleCodeExporter commented 9 years ago
Yep, the latest hg clone seems to work.  I'm seeing one possible leak now on a 
different resource which only reveals itself on this latest kedr, or if I use 
the older 0.5 and switch all of my kzalloc_node()'s to kzalloc() (otherwise 
it's masked).  I thought I recalled having a clean run doing this before, but, 
no doubt it's a real module problem.

Bug as described is fixed, thanks!

Original comment by bciph...@gmail.com on 19 Aug 2014 at 12:58

GoogleCodeExporter commented 9 years ago

Original comment by euspec...@gmail.com on 19 Aug 2014 at 1:11