Skip to contentSkip to conversation

linux-3.7.4: kmemleak in sctp_sysctl_net_register()?

PATCH In review Martin Mokrejs 5 participants 17 messages Jan 23, 2013 – Mar 5, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi,
today I got the following report from the kernel, looks it happened when
I started/used/quit chromium browser. I haven't seen this with 3.7.1 but I use builtin kmemleak detector only for 2-3 weeks.

unreferenced object 0xffff880402d08000 (size 2048):
comm "chrome_sandbox", pid 18437, jiffies 4310887172 (age 9097.630s) hex dump (first 32 bytes):

    b2 68 89 81 ff ff ff ff 20 04 04 f8 01 88 ff ff  .h...... .......
    04 00 00 00 a4 01 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff815b4aad>] kmemleak_alloc+0x21/0x3e
    [<ffffffff81110352>] slab_post_alloc_hook+0x28/0x2a
    [<ffffffff81113fad>] __kmalloc_track_caller+0xf1/0x104
    [<ffffffff810f10c2>] kmemdup+0x1b/0x30
    [<ffffffff81571e9f>] sctp_sysctl_net_register+0x1f/0x72
    [<ffffffff8155d305>] sctp_net_init+0x100/0x39f
    [<ffffffff814ad53c>] ops_init+0xc6/0xf5
    [<ffffffff814ad5b7>] setup_net+0x4c/0xd0
    [<ffffffff814ada5e>] copy_net_ns+0x6d/0xd6
    [<ffffffff810938b1>] create_new_namespaces+0xd7/0x147
    [<ffffffff810939f4>] copy_namespaces+0x63/0x99
    [<ffffffff81076733>] copy_process+0xa65/0x1233
    [<ffffffff81077030>] do_fork+0x10b/0x271
    [<ffffffff8100a0e9>] sys_clone+0x23/0x25
    [<ffffffff815dda73>] stub_clone+0x13/0x20
    [<ffffffffffffffff>] 0xffffffffffffffff

Please let me know if you need more info, like dmesg, .config or other. Hope this helps.
Martin

#1 lore raw

PATCH 1/1 SCTP: Free the per-net sysctl table on net exit.

Per-net sysctl table needs to be explicitly freed at net exit. Otherwise we see the following with kmemleak:

unreferenced object 0xffff880402d08000 (size 2048):
comm "chrome_sandbox", pid 18437, jiffies 4310887172 (age 9097.630s) hex dump (first 32 bytes):

    b2 68 89 81 ff ff ff ff 20 04 04 f8 01 88 ff ff  .h...... .......
    04 00 00 00 a4 01 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff815b4aad>] kmemleak_alloc+0x21/0x3e
    [<ffffffff81110352>] slab_post_alloc_hook+0x28/0x2a
    [<ffffffff81113fad>] __kmalloc_track_caller+0xf1/0x104
    [<ffffffff810f10c2>] kmemdup+0x1b/0x30
    [<ffffffff81571e9f>] sctp_sysctl_net_register+0x1f/0x72
    [<ffffffff8155d305>] sctp_net_init+0x100/0x39f
    [<ffffffff814ad53c>] ops_init+0xc6/0xf5
    [<ffffffff814ad5b7>] setup_net+0x4c/0xd0
    [<ffffffff814ada5e>] copy_net_ns+0x6d/0xd6
    [<ffffffff810938b1>] create_new_namespaces+0xd7/0x147
    [<ffffffff810939f4>] copy_namespaces+0x63/0x99
    [<ffffffff81076733>] copy_process+0xa65/0x1233
    [<ffffffff81077030>] do_fork+0x10b/0x271
    [<ffffffff8100a0e9>] sys_clone+0x23/0x25
    [<ffffffff815dda73>] stub_clone+0x13/0x20
    [<ffffffffffffffff>] 0xffffffffffffffff
---
 net/sctp/sysctl.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/sctp/sysctl.c +4 -0
index 043889a..cd5712f 100644
@@ -366,7 +366,11 @@ int sctp_sysctl_net_register(struct net *net)
 
 void sctp_sysctl_net_unregister(struct net *net)
 {
+	struct ctl_table *table;
+
+	table = net->sctp.sysctl_hdr->ctl_table_arg;
 	unregister_net_sysctl_table(net->sctp.sysctl_header);
+	kfree(table);
 }
 
 static struct ctl_table_header * sctp_sysctl_header;
Signature · 1 line
1.7.7.6
Acked-by on v1 1/1
#2 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit.

Quoted 57 lines · Vlad Yasevich

Per-net sysctl table needs to be explicitly freed at net exit. Otherwise we see the following with kmemleak:

unreferenced object 0xffff880402d08000 (size 2048):
comm "chrome_sandbox", pid 18437, jiffies 4310887172 (age 9097.630s) hex dump (first 32 bytes):

    b2 68 89 81 ff ff ff ff 20 04 04 f8 01 88 ff ff  .h...... .......
    04 00 00 00 a4 01 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff815b4aad>] kmemleak_alloc+0x21/0x3e
    [<ffffffff81110352>] slab_post_alloc_hook+0x28/0x2a
    [<ffffffff81113fad>] __kmalloc_track_caller+0xf1/0x104
    [<ffffffff810f10c2>] kmemdup+0x1b/0x30
    [<ffffffff81571e9f>] sctp_sysctl_net_register+0x1f/0x72
    [<ffffffff8155d305>] sctp_net_init+0x100/0x39f
    [<ffffffff814ad53c>] ops_init+0xc6/0xf5
    [<ffffffff814ad5b7>] setup_net+0x4c/0xd0
    [<ffffffff814ada5e>] copy_net_ns+0x6d/0xd6
    [<ffffffff810938b1>] create_new_namespaces+0xd7/0x147
    [<ffffffff810939f4>] copy_namespaces+0x63/0x99
    [<ffffffff81076733>] copy_process+0xa65/0x1233
    [<ffffffff81077030>] do_fork+0x10b/0x271
    [<ffffffff8100a0e9>] sys_clone+0x23/0x25
    [<ffffffff815dda73>] stub_clone+0x13/0x20
    [<ffffffffffffffff>] 0xffffffffffffffff
---
 net/sctp/sysctl.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/sctp/sysctl.c +4 -0
index 043889a..cd5712f 100644
@@ -366,7 +366,11 @@ int sctp_sysctl_net_register(struct net *net)
 
 void sctp_sysctl_net_unregister(struct net *net)
 {
+	struct ctl_table *table;
+
+	table = net->sctp.sysctl_hdr->ctl_table_arg;
 	unregister_net_sysctl_table(net->sctp.sysctl_header);
+	kfree(table);
 }
 
 static struct ctl_table_header * sctp_sysctl_header;
Signature · 6 lines
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reviewed-by
#3 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit.

Quoted 53 lines · Neil Horman
Quoted 52 lines · Vlad Yasevich

Per-net sysctl table needs to be explicitly freed at net exit. Otherwise we see the following with kmemleak:

unreferenced object 0xffff880402d08000 (size 2048):
comm "chrome_sandbox", pid 18437, jiffies 4310887172 (age 9097.630s) hex dump (first 32 bytes):

    b2 68 89 81 ff ff ff ff 20 04 04 f8 01 88 ff ff  .h...... .......
    04 00 00 00 a4 01 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff815b4aad>] kmemleak_alloc+0x21/0x3e
    [<ffffffff81110352>] slab_post_alloc_hook+0x28/0x2a
    [<ffffffff81113fad>] __kmalloc_track_caller+0xf1/0x104
    [<ffffffff810f10c2>] kmemdup+0x1b/0x30
    [<ffffffff81571e9f>] sctp_sysctl_net_register+0x1f/0x72
    [<ffffffff8155d305>] sctp_net_init+0x100/0x39f
    [<ffffffff814ad53c>] ops_init+0xc6/0xf5
    [<ffffffff814ad5b7>] setup_net+0x4c/0xd0
    [<ffffffff814ada5e>] copy_net_ns+0x6d/0xd6
    [<ffffffff810938b1>] create_new_namespaces+0xd7/0x147
    [<ffffffff810939f4>] copy_namespaces+0x63/0x99
    [<ffffffff81076733>] copy_process+0xa65/0x1233
    [<ffffffff81077030>] do_fork+0x10b/0x271
    [<ffffffff8100a0e9>] sys_clone+0x23/0x25
    [<ffffffff815dda73>] stub_clone+0x13/0x20
    [<ffffffffffffffff>] 0xffffffffffffffff
---
 net/sctp/sysctl.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/sctp/sysctl.c +4 -0
index 043889a..cd5712f 100644
@@ -366,7 +366,11 @@ int sctp_sysctl_net_register(struct net *net)
 
 void sctp_sysctl_net_unregister(struct net *net)
 {
+	struct ctl_table *table;
+
+	table = net->sctp.sysctl_hdr->ctl_table_arg;
 	unregister_net_sysctl_table(net->sctp.sysctl_header);
+	kfree(table);
 }
 
 static struct ctl_table_header * sctp_sysctl_header;
Signature · 1 line
1.7.7.6
Quoted 6 lines
Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Doh. I should have known better.

Eric

maintainer
#4 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit.

In reply to Vlad Yasevich

RnJvbTogVmxhZCBZYXNldmljaCA8dnlhc2V2aWNoQGdtYWlsLmNvbT4NCkRhdGU6IFRodSwgMjQg SmFuIDIwMTMgMTE6MDI6NDcgLTA1MDANCg0KPiBAQCAtMzY2LDcgKzM2NiwxMSBAQCBpbnQgc2N0 cF9zeXNjdGxfbmV0X3JlZ2lzdGVyKHN0cnVjdCBuZXQgKm5ldCkNCj4gIA0KPiAgdm9pZCBzY3Rw X3N5c2N0bF9uZXRfdW5yZWdpc3RlcihzdHJ1Y3QgbmV0ICpuZXQpDQo+ICB7DQo+ICsJc3RydWN0 IGN0bF90YWJsZSAqdGFibGU7DQo+ICsNCj4gKwl0YWJsZSA9IG5ldC0+c2N0cC5zeXNjdGxfaGRy LT5jdGxfdGFibGVfYXJnOw0KPiAgCXVucmVnaXN0ZXJfbmV0X3N5c2N0bF90YWJsZShuZXQtPnNj dHAuc3lzY3RsX2hlYWRlcik7DQo+ICsJa2ZyZWUodGFibGUpOw0KPiAgfQ0KDQpJbiB3aGF0IHRy ZWUgZG9lcyB0aGlzIGNvbXBpbGU/ICBJIHRyaWVkIGJvdGggJ25ldCcgYW5kICduZXQtbmV4dCcN CmFuZCBnb3QgdGhlIHNhbWUgZXhhY3QgcmVzdWx0Og0KDQpuZXQvc2N0cC9zeXNjdGwuYzogSW4g ZnVuY3Rpb24goXNjdHBfc3lzY3RsX25ldF91bnJlZ2lzdGVyojoNCm5ldC9zY3RwL3N5c2N0bC5j OjM3MToxOTogZXJyb3I6IKFzdHJ1Y3QgbmV0bnNfc2N0cKIgaGFzIG5vIG1lbWJlciBuYW1lZCCh c3lzY3RsX2hkcqINCm1ha2VbMV06ICoqKiBbbmV0L3NjdHAvc3lzY3RsLm9dIEVycm9yIDENCm1h a2U6ICoqKiBbbmV0L3NjdHAvc3lzY3RsLm9dIEVycm9yIDINCg=

#5 lore raw

PATCH 1/1 SCTP: Free the per-net sysctl table on net exit.

Per-net sysctl table needs to be explicitly freed at net exit. Otherwise we see the following with kmemleak:

unreferenced object 0xffff880402d08000 (size 2048):
comm "chrome_sandbox", pid 18437, jiffies 4310887172 (age 9097.630s) hex dump (first 32 bytes):

    b2 68 89 81 ff ff ff ff 20 04 04 f8 01 88 ff ff  .h...... .......
    04 00 00 00 a4 01 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff815b4aad>] kmemleak_alloc+0x21/0x3e
    [<ffffffff81110352>] slab_post_alloc_hook+0x28/0x2a
    [<ffffffff81113fad>] __kmalloc_track_caller+0xf1/0x104
    [<ffffffff810f10c2>] kmemdup+0x1b/0x30
    [<ffffffff81571e9f>] sctp_sysctl_net_register+0x1f/0x72
    [<ffffffff8155d305>] sctp_net_init+0x100/0x39f
    [<ffffffff814ad53c>] ops_init+0xc6/0xf5
    [<ffffffff814ad5b7>] setup_net+0x4c/0xd0
    [<ffffffff814ada5e>] copy_net_ns+0x6d/0xd6
    [<ffffffff810938b1>] create_new_namespaces+0xd7/0x147
    [<ffffffff810939f4>] copy_namespaces+0x63/0x99
    [<ffffffff81076733>] copy_process+0xa65/0x1233
    [<ffffffff81077030>] do_fork+0x10b/0x271
    [<ffffffff8100a0e9>] sys_clone+0x23/0x25
    [<ffffffff815dda73>] stub_clone+0x13/0x20
    [<ffffffffffffffff>] 0xffffffffffffffff

I fixed the spelling of sysctl_header so the code actually compiles. -- EWB.

---
 net/sctp/sysctl.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/sctp/sysctl.c +4 -0
index 043889a..cd5712f 100644
@@ -366,7 +366,11 @@ int sctp_sysctl_net_register(struct net *net)
 
 void sctp_sysctl_net_unregister(struct net *net)
 {
+	struct ctl_table *table;
+
+	table = net->sctp.sysctl_hdr->ctl_table_arg;
 	unregister_net_sysctl_table(net->sctp.sysctl_header);
+	kfree(table);
 }
 
 static struct ctl_table_header * sctp_sysctl_header;
Signature · 1 line
1.7.5.4
#6 lore raw

PATCH 1/1 SCTP: Free the per-net sysctl table on net exit. v2

From: Vlad Yasevich <[email protected]>
Date: Thu, 24 Jan 2013 11:02:47 -0500

Per-net sysctl table needs to be explicitly freed at net exit. Otherwise we see the following with kmemleak:

unreferenced object 0xffff880402d08000 (size 2048):
comm "chrome_sandbox", pid 18437, jiffies 4310887172 (age 9097.630s) hex dump (first 32 bytes):

    b2 68 89 81 ff ff ff ff 20 04 04 f8 01 88 ff ff  .h...... .......
    04 00 00 00 a4 01 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff815b4aad>] kmemleak_alloc+0x21/0x3e
    [<ffffffff81110352>] slab_post_alloc_hook+0x28/0x2a
    [<ffffffff81113fad>] __kmalloc_track_caller+0xf1/0x104
    [<ffffffff810f10c2>] kmemdup+0x1b/0x30
    [<ffffffff81571e9f>] sctp_sysctl_net_register+0x1f/0x72
    [<ffffffff8155d305>] sctp_net_init+0x100/0x39f
    [<ffffffff814ad53c>] ops_init+0xc6/0xf5
    [<ffffffff814ad5b7>] setup_net+0x4c/0xd0
    [<ffffffff814ada5e>] copy_net_ns+0x6d/0xd6
    [<ffffffff810938b1>] create_new_namespaces+0xd7/0x147
    [<ffffffff810939f4>] copy_namespaces+0x63/0x99
    [<ffffffff81076733>] copy_process+0xa65/0x1233
    [<ffffffff81077030>] do_fork+0x10b/0x271
    [<ffffffff8100a0e9>] sys_clone+0x23/0x25
    [<ffffffff815dda73>] stub_clone+0x13/0x20
    [<ffffffffffffffff>] 0xffffffffffffffff

I fixed the spelling of sysctl_header so the code actually compiles. -- EWB.

---

The typo is fixed in the patch this time in addition to my test tree.

 net/sctp/sysctl.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/sctp/sysctl.c +4 -0
index 043889a..bf3c6e8 100644
@@ -366,7 +366,11 @@ int sctp_sysctl_net_register(struct net *net)
 
 void sctp_sysctl_net_unregister(struct net *net)
 {
+	struct ctl_table *table;
+
+	table = net->sctp.sysctl_header->ctl_table_arg;
 	unregister_net_sysctl_table(net->sctp.sysctl_header);
+	kfree(table);
 }
 
 static struct ctl_table_header * sctp_sysctl_header;
Signature · 1 line
1.7.5.4
maintainer Applied
#7 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit. v2

From: [email protected] (Eric W. Biederman)
Date: Sun, 27 Jan 2013 19:25:11 -0800

Quoted 2 lines

The typo is fixed in the patch this time in addition to my test tree.

Applied, thanks for fixing this up Eric.

#8 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit. v2

Quoted 7 lines · David Miller

From: [email protected] (Eric W. Biederman)
Date: Sun, 27 Jan 2013 19:25:11 -0800

Quoted 2 lines

The typo is fixed in the patch this time in addition to my test tree.

Applied, thanks for fixing this up Eric.

I did check now how come that I patched my 3.7.4 on Jan 24. Looks like -head or -next has different namings. For me, the original patch applied fine. So far I haven't hit the memleak although it happened only once to me before the patch. But probably I can confirm say Tested-by:.

#
-rw-r--r-- 1 root root 8435 Jan 24 17:12 /usr/src/linux-3.7.4/net/sctp/sysctl.c -rw-rw-r-- 1 root root 8347 Jan 21 20:45 /usr/src/linux-3.7.4/net/sctp/sysctl.c.orig

# ls -la /usr/src/linux-3.7.4/net/sctp/sysctl.o
-rw-r--r-- 1 root root 246144 Jan 21 22:37 /usr/src/linux-3.7.4/net/sctp/sysctl.o
# ls -la /usr/src/linux-3.7.4/arch/x86/boot/bzImage 
-rw-r--r-- 1 root root 3794592 Jan 21 22:45 /usr/src/linux-3.7.4/arch/x86/boot/bzImage
#

If 3.7 and earlier need the old patch (like I currently think) please make them aware of that.
Martin

#9 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit. v2

Quoted 7 lines · Martin Mokrejs
Quoted 6 lines · David Miller

From: [email protected] (Eric W. Biederman)
Date: Sun, 27 Jan 2013 19:25:11 -0800

Quoted 2 lines

The typo is fixed in the patch this time in addition to my test tree.

Quoted 6 lines
Quoted 1 line

Applied, thanks for fixing this up Eric.

I did check now how come that I patched my 3.7.4 on Jan 24. Looks like -head or -next has different namings. For me, the original patch applied fine. So far I haven't hit the memleak although it happened only once to me before the patch.

The problem isn't that the patch doesn't apply the problem is that the patch did not build. The naming has not changed in the git history.

Quoted 10 lines

But probably I can confirm say Tested-by:.

#

(quoted diff) +0 -2
-rw-r--r-- 1 root root  8435 Jan 24 17:12 /usr/src/linux-3.7.4/net/sctp/sysctl.c
-rw-rw-r-- 1 root root  8347 Jan 21 20:45 /usr/src/linux-3.7.4/net/sctp/sysctl.c.orig
# ls -la /usr/src/linux-3.7.4/net/sctp/sysctl.o
-rw-r--r-- 1 root root 246144 Jan 21 22:37 /usr/src/linux-3.7.4/net/sctp/sysctl.o
# ls -la /usr/src/linux-3.7.4/arch/x86/boot/bzImage 
-rw-r--r-- 1 root root 3794592 Jan 21 22:45 /usr/src/linux-3.7.4/arch/x86/boot/bzImage
#

It doesn't look look like you rebuilt anything after you applied the changes to net/sctp/sysctl.c. sysctl.o and bzImage are both 3 days older.

Eric

#10 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit. v2

Hi Eric,

Quoted 21 lines · Eric W. Biederman
Quoted 7 lines · Martin Mokrejs
Quoted 6 lines · David Miller

From: [email protected] (Eric W. Biederman)
Date: Sun, 27 Jan 2013 19:25:11 -0800

Quoted 2 lines

The typo is fixed in the patch this time in addition to my test tree.

Quoted 6 lines
Quoted 1 line

Applied, thanks for fixing this up Eric.

I did check now how come that I patched my 3.7.4 on Jan 24. Looks like -head or -next has different namings. For me, the original patch applied fine. So far I haven't hit the memleak although it happened only once to me before the patch.

The problem isn't that the patch doesn't apply the problem is that the patch did not build. The naming has not changed in the git history.

Quoted 2 lines

But probably I can confirm say Tested-by:.

Quoted 11 lines
Quoted 8 lines

#

(quoted diff) +0 -2
-rw-r--r-- 1 root root  8435 Jan 24 17:12 /usr/src/linux-3.7.4/net/sctp/sysctl.c
-rw-rw-r-- 1 root root  8347 Jan 21 20:45 /usr/src/linux-3.7.4/net/sctp/sysctl.c.orig
# ls -la /usr/src/linux-3.7.4/net/sctp/sysctl.o
-rw-r--r-- 1 root root 246144 Jan 21 22:37 /usr/src/linux-3.7.4/net/sctp/sysctl.o
# ls -la /usr/src/linux-3.7.4/arch/x86/boot/bzImage 
-rw-r--r-- 1 root root 3794592 Jan 21 22:45 /usr/src/linux-3.7.4/arch/x86/boot/bzImage
#

It doesn't look look like you rebuilt anything after you applied the changes to net/sctp/sysctl.c. sysctl.o and bzImage are both 3 days older.

Ah, I must have been really blind. Thanks for pointing that out. I should really start to do:

make bzImage && make modules && make modules_install && cp arch/x86_64/boot/bzImage /boot/vmlinuz-$ver

echo "silly me, make(1) did not delete the old bzImage"

So I haven't tested the patch yet. doh. Provided I am running 3 days without reproducing the original memleak on an unpatched kernel I doubt I can easily prove it after a reboot. :( Will probably stay untested. But compiles fine here. ;-)

Thanks,
Martin

#11 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit. v2

Quoted 9 lines · Martin Mokrejs

Hi Eric,

Quoted 6 lines · Eric W. Biederman
Quoted 4 lines · Martin Mokrejs
Quoted 3 lines · David Miller

From: [email protected] (Eric W. Biederman)
Date: Sun, 27 Jan 2013 19:25:11 -0800

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

The typo is fixed in the patch this time in addition to my test tree.

Applied, thanks for fixing this up Eric.

So I haven't tested the patch yet. doh. Provided I am running 3 days without reproducing the original memleak on an unpatched kernel I doubt I can easily prove it after a reboot.

Umm, I spoke too early. It did happen again during these 3 days on unpatched 3.7.4:

unreferenced object 0xffff880402769030 (size 2048):
comm "chrome_sandbox", pid 4720, jiffies 4294966701 (age 285697.590s) hex dump (first 32 bytes):

    b2 68 89 81 ff ff ff ff 20 84 4f d8 03 88 ff ff  .h...... .O.....
    04 00 00 00 a4 01 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff815b4aad>] kmemleak_alloc+0x21/0x3e
    [<ffffffff81110352>] slab_post_alloc_hook+0x28/0x2a
    [<ffffffff81113fad>] __kmalloc_track_caller+0xf1/0x104
    [<ffffffff810f10c2>] kmemdup+0x1b/0x30
    [<ffffffff81571e9f>] sctp_sysctl_net_register+0x1f/0x72
    [<ffffffff8155d305>] sctp_net_init+0x100/0x39f
    [<ffffffff814ad53c>] ops_init+0xc6/0xf5
    [<ffffffff814ad5b7>] setup_net+0x4c/0xd0
    [<ffffffff814ada5e>] copy_net_ns+0x6d/0xd6
    [<ffffffff810938b1>] create_new_namespaces+0xd7/0x147
    [<ffffffff810939f4>] copy_namespaces+0x63/0x99
    [<ffffffff81076733>] copy_process+0xa65/0x1233
    [<ffffffff81077030>] do_fork+0x10b/0x271
    [<ffffffff8100a0e9>] sys_clone+0x23/0x25
    [<ffffffff815dda73>] stub_clone+0x13/0x20
    [<ffffffffffffffff>] 0xffffffffffffffff

But I won't make it to a reboot in next 2-3 days to test the patch v2, sorry.

Martin

#12 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit. v2

Quoted 43 lines · Martin Mokrejs
Quoted 9 lines · Martin Mokrejs

Hi Eric,

Quoted 6 lines · Eric W. Biederman
Quoted 4 lines · Martin Mokrejs
Quoted 3 lines · David Miller

From: [email protected] (Eric W. Biederman)
Date: Sun, 27 Jan 2013 19:25:11 -0800

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

The typo is fixed in the patch this time in addition to my test tree.

Applied, thanks for fixing this up Eric.

So I haven't tested the patch yet. doh. Provided I am running 3 days without reproducing the original memleak on an unpatched kernel I doubt I can easily prove it after a reboot.

Umm, I spoke too early. It did happen again during these 3 days on unpatched 3.7.4:

unreferenced object 0xffff880402769030 (size 2048):
comm "chrome_sandbox", pid 4720, jiffies 4294966701 (age 285697.590s) hex dump (first 32 bytes):

    b2 68 89 81 ff ff ff ff 20 84 4f d8 03 88 ff ff  .h...... .O.....
    04 00 00 00 a4 01 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff815b4aad>] kmemleak_alloc+0x21/0x3e
    [<ffffffff81110352>] slab_post_alloc_hook+0x28/0x2a
    [<ffffffff81113fad>] __kmalloc_track_caller+0xf1/0x104
    [<ffffffff810f10c2>] kmemdup+0x1b/0x30
    [<ffffffff81571e9f>] sctp_sysctl_net_register+0x1f/0x72
    [<ffffffff8155d305>] sctp_net_init+0x100/0x39f
    [<ffffffff814ad53c>] ops_init+0xc6/0xf5
    [<ffffffff814ad5b7>] setup_net+0x4c/0xd0
    [<ffffffff814ada5e>] copy_net_ns+0x6d/0xd6
    [<ffffffff810938b1>] create_new_namespaces+0xd7/0x147
    [<ffffffff810939f4>] copy_namespaces+0x63/0x99
    [<ffffffff81076733>] copy_process+0xa65/0x1233
    [<ffffffff81077030>] do_fork+0x10b/0x271
    [<ffffffff8100a0e9>] sys_clone+0x23/0x25
    [<ffffffff815dda73>] stub_clone+0x13/0x20
    [<ffffffffffffffff>] 0xffffffffffffffff
Quoted 1 line

But I won't make it to a reboot in next 2-3 days to test the patch v2, sorry.

No biggy the logic remains the same and the fix in the patch is clrearly needed from an inspection of the code.

Eric

#13 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit. v2

In reply to Eric W. Biederman

Hi,
this is to let you know that this patch is still not in stable.
I just fetched 3.7.10 and reproduced the original problem.
I bet this slipped through because there was an initial patch from Vlad Yasevich on Jan 24, then a follow-up patch from Eric Biedermann which did not compile and finally a v2 patch from E. B which did compile.

For me the last, v2 patch applies (with some hunk) to 3.7.10 and compiles
fine.

Thanks,
martin

Quoted 61 lines · Eric W. Biederman

From: Vlad Yasevich <[email protected]>
Date: Thu, 24 Jan 2013 11:02:47 -0500

Per-net sysctl table needs to be explicitly freed at net exit. Otherwise we see the following with kmemleak:

unreferenced object 0xffff880402d08000 (size 2048):
comm "chrome_sandbox", pid 18437, jiffies 4310887172 (age 9097.630s) hex dump (first 32 bytes):

    b2 68 89 81 ff ff ff ff 20 04 04 f8 01 88 ff ff  .h...... .......
    04 00 00 00 a4 01 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff815b4aad>] kmemleak_alloc+0x21/0x3e
    [<ffffffff81110352>] slab_post_alloc_hook+0x28/0x2a
    [<ffffffff81113fad>] __kmalloc_track_caller+0xf1/0x104
    [<ffffffff810f10c2>] kmemdup+0x1b/0x30
    [<ffffffff81571e9f>] sctp_sysctl_net_register+0x1f/0x72
    [<ffffffff8155d305>] sctp_net_init+0x100/0x39f
    [<ffffffff814ad53c>] ops_init+0xc6/0xf5
    [<ffffffff814ad5b7>] setup_net+0x4c/0xd0
    [<ffffffff814ada5e>] copy_net_ns+0x6d/0xd6
    [<ffffffff810938b1>] create_new_namespaces+0xd7/0x147
    [<ffffffff810939f4>] copy_namespaces+0x63/0x99
    [<ffffffff81076733>] copy_process+0xa65/0x1233
    [<ffffffff81077030>] do_fork+0x10b/0x271
    [<ffffffff8100a0e9>] sys_clone+0x23/0x25
    [<ffffffff815dda73>] stub_clone+0x13/0x20
    [<ffffffffffffffff>] 0xffffffffffffffff

I fixed the spelling of sysctl_header so the code actually compiles. -- EWB.

---

The typo is fixed in the patch this time in addition to my test tree.

 net/sctp/sysctl.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/sctp/sysctl.c +4 -0
index 043889a..bf3c6e8 100644
@@ -366,7 +366,11 @@ int sctp_sysctl_net_register(struct net *net)
 
 void sctp_sysctl_net_unregister(struct net *net)
 {
+	struct ctl_table *table;
+
+	table = net->sctp.sysctl_header->ctl_table_arg;
 	unregister_net_sysctl_table(net->sctp.sysctl_header);
+	kfree(table);
 }
 
 static struct ctl_table_header * sctp_sysctl_header;
maintainer
#14 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit. v2

From: Martin Mokrejs <[email protected]>
Date: Tue, 05 Mar 2013 10:05:06 +0100

Quoted 2 lines

this is to let you know that this patch is still not in stable.
I just fetched 3.7.10 and reproduced the original problem.

3.7.x is end of life and no longer being actively maintained.

#15 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit. v2

Quoted 7 lines · David Miller

From: Martin Mokrejs <[email protected]>
Date: Tue, 05 Mar 2013 10:05:06 +0100

Quoted 2 lines

this is to let you know that this patch is still not in stable.
I just fetched 3.7.10 and reproduced the original problem.

3.7.x is end of life and no longer being actively maintained.

??? 3.7.10 was released on 2013-02-27.

I disagree with making a kernel line 3.7 released on 2012-12-11 unsupported while 3.8.0 was released just on 2013-02-18. That is way too new. Sorry to say that but I don't expect 3.8 to be tested properly like 3.7.4 was NOT in January 2013 when I reported the particular sctp bug, and several others in USB, pci/e hotplug, etc. Now, with 3.8.2 being out one day already I will hit for sure other bugs. I really want something stable. For USB3.0 I need 3.2.x at least, actually 3.5 for some better URB handling ... The already buggy (in 3.2.x PCI/e hotplug) got reworked in about 3.5 into another buggy behavior so another workaround had to be invented.

Of course I do appreciate your work but if somebody bothered to report a bug and some devs bothered to provide patches, you should let the fix go into life. It is waiting in the patchwork since 1,5 month. By that time, 3.7.x was the current, latest&greatest stable. I just don't agree.

Sorry for such a rant, I couldn't resist. ;)
Martin

maintainer
#16 lore raw

Re: [PATCH] SCTP: Free the per-net sysctl table on net exit. v2

From: Martin Mokrejs <[email protected]>
Date: Tue, 05 Mar 2013 22:04:05 +0100

Quoted 1 line

Sorry for such a rant, I couldn't resist. ;)

Thankfully none of the stable maintainers had to actually read your rant because you got the stable address wrong.