From: Steven Rostedt <rostedt@goodmis.org>
To: David Miller <davem@davemloft.net>, LKML <linux-kernel@vger.kernel.org>
Cc: netdev@vger.kernel.org, viro@zeniv.linux.org.uk,
ebiederm@xmission.com, tixxdz@opendz.org
Subject: [PATCH] net: Surpress kmemleak messages on sysctl paths
Date: Mon, 21 May 2012 20:43:12 -0400 [thread overview]
Message-ID: <1337647392.13348.14.camel@gandalf.stny.rr.com> (raw)
The network code allocates ctl_table_headers that are used for the life
of the kernel. These headers are registered and never unregistered. The
head pointer is allocated and not referenced, as it never needs to be
unregistered, and the kmemleak detector triggers these as false
positives:
unreferenced object 0xffff88007843fec0 (size 128):
comm "swapper/0", pid 1, jiffies 4294669964 (age 12611.525s)
hex dump (first 32 bytes):
00 bb 59 82 ff ff ff ff 00 00 00 00 01 00 00 00 ..Y.............
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8146b590>] kmemleak_alloc+0x73/0x98
[<ffffffff8110a935>] kmemleak_alloc_recursive.constprop.42+0x16/0x18
[<ffffffff8110b852>] __kmalloc+0x107/0x153
[<ffffffff8116fa72>] kzalloc.constprop.8+0xe/0x10
[<ffffffff8116fe2e>] __register_sysctl_table+0x46/0x39c
[<ffffffff811703a7>] __register_sysctl_paths+0xbf/0x160
[<ffffffff81170463>] register_sysctl_paths+0x1b/0x1d
[<ffffffff81b1c769>] sysctl_core_init+0x17/0x38
[<ffffffff81000229>] do_one_initcall+0x7f/0x13a
[<ffffffff81ae5d00>] kernel_init+0x148/0x1cc
[<ffffffff81493174>] kernel_thread_helper+0x4/0x10
[<ffffffffffffffff>] 0xffffffffffffffff
unreferenced object 0xffff8800784330c0 (size 128):
comm "swapper/0", pid 1, jiffies 4294669968 (age 12611.521s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8146b590>] kmemleak_alloc+0x73/0x98
[<ffffffff8110a935>] kmemleak_alloc_recursive.constprop.42+0x16/0x18
[<ffffffff8110b852>] __kmalloc+0x107/0x153
[<ffffffff8116fa72>] kzalloc.constprop.8+0xe/0x10
[<ffffffff811703c9>] __register_sysctl_paths+0xe1/0x160
[<ffffffff81170463>] register_sysctl_paths+0x1b/0x1d
[<ffffffff81b1d897>] ip_static_sysctl_init+0x17/0x19
[<ffffffff81b1e1f4>] inet_init+0x9e/0x29c
[<ffffffff81000229>] do_one_initcall+0x7f/0x13a
[<ffffffff81ae5d00>] kernel_init+0x148/0x1cc
[<ffffffff81493174>] kernel_thread_helper+0x4/0x10
[<ffffffffffffffff>] 0xffffffffffffffff
unreferenced object 0xffff88007843fdc0 (size 128):
comm "swapper/0", pid 1, jiffies 4294669969 (age 12611.520s)
hex dump (first 32 bytes):
d0 d8 59 82 ff ff ff ff 00 00 00 00 01 00 00 00 ..Y.............
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8146b590>] kmemleak_alloc+0x73/0x98
[<ffffffff8110a935>] kmemleak_alloc_recursive.constprop.42+0x16/0x18
[<ffffffff8110b852>] __kmalloc+0x107/0x153
[<ffffffff8116fa72>] kzalloc.constprop.8+0xe/0x10
[<ffffffff8116fe2e>] __register_sysctl_table+0x46/0x39c
[<ffffffff8117024a>] register_leaf_sysctl_tables+0xc6/0x147
[<ffffffff8117029f>] register_leaf_sysctl_tables+0x11b/0x147
[<ffffffff811703f4>] __register_sysctl_paths+0x10c/0x160
[<ffffffff81170463>] register_sysctl_paths+0x1b/0x1d
[<ffffffff81b1d897>] ip_static_sysctl_init+0x17/0x19
[<ffffffff81b1e1f4>] inet_init+0x9e/0x29c
[<ffffffff81000229>] do_one_initcall+0x7f/0x13a
[<ffffffff81ae5d00>] kernel_init+0x148/0x1cc
[<ffffffff81493174>] kernel_thread_helper+0x4/0x10
[<ffffffffffffffff>] 0xffffffffffffffff
Tell kmemleak to not consider these allocations as leaks.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 0c28508..0bc5e0d 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -11,6 +11,7 @@
#include <linux/socket.h>
#include <linux/netdevice.h>
#include <linux/ratelimit.h>
+#include <linux/kmemleak.h>
#include <linux/vmalloc.h>
#include <linux/init.h>
#include <linux/slab.h>
@@ -255,9 +256,12 @@ static __net_initdata struct pernet_operations sysctl_core_ops = {
static __init int sysctl_core_init(void)
{
static struct ctl_table empty[1];
+ struct ctl_table_header *hdr;
- register_sysctl_paths(net_core_path, empty);
- register_net_sysctl_rotable(net_core_path, net_core_table);
+ hdr = register_sysctl_paths(net_core_path, empty);
+ kmemleak_not_leak(hdr);
+ hdr = register_net_sysctl_rotable(net_core_path, net_core_table);
+ kmemleak_not_leak(hdr);
return register_pernet_subsys(&sysctl_core_ops);
}
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 167ea10..35aeaa7 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -87,6 +87,7 @@
#include <linux/pkt_sched.h>
#include <linux/mroute.h>
#include <linux/netfilter_ipv4.h>
+#include <linux/kmemleak.h>
#include <linux/random.h>
#include <linux/jhash.h>
#include <linux/rcupdate.h>
@@ -3505,6 +3506,9 @@ int __init ip_rt_init(void)
*/
void __init ip_static_sysctl_init(void)
{
- register_sysctl_paths(ipv4_path, ipv4_skeleton);
+ struct ctl_table_header *hdr;
+
+ hdr = register_sysctl_paths(ipv4_path, ipv4_skeleton);
+ kmemleak_not_leak(hdr);
}
#endif
next reply other threads:[~2012-05-22 0:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-22 0:43 Steven Rostedt [this message]
2012-05-22 14:41 ` [PATCH] net: Surpress kmemleak messages on sysctl paths Eric W. Biederman
2012-05-22 14:51 ` Steven Rostedt
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=1337647392.13348.14.camel@gandalf.stny.rr.com \
--to=rostedt@goodmis.org \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tixxdz@opendz.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;
as well as URLs for NNTP newsgroup(s).