Skip to contentSkip to conversation

kobject leak in next-20080829

PATCH Superseded Alexey Dobriyan 3 participants 10 messages Aug 30, 2008 – Sep 23, 2008

lore
Share & tools
lore
#0 lore raw
	size-32: 3511 kvasprintf+0x57/0x90
	size-64: 3059 kobject_create+0x1c/0x40

These two buddies increase after every "modprobe; rmmod" sequence.

#1 lore raw
Quoted 4 lines · Alexey Dobriyan
	size-32: 3511 kvasprintf+0x57/0x90
	size-64: 3059 kobject_create+0x1c/0x40

These two buddies increase after every "modprobe; rmmod" sequence.

Do they also do so in mainline?

thanks,

greg k-h

#2 lore raw

Re: kobject leak in next-20080829 (and mainline)

Quoted 7 lines · Greg KH
Quoted 4 lines · Alexey Dobriyan
	size-32: 3511 kvasprintf+0x57/0x90
	size-64: 3059 kobject_create+0x1c/0x40

These two buddies increase after every "modprobe; rmmod" sequence.

Do they also do so in mainline?

Yep, same bug in mainline.

#3 lore raw

Re: kobject leak in next-20080829 (and mainline)

Quoted 10 lines · Alexey Dobriyan
Quoted 7 lines · Greg KH
Quoted 4 lines · Alexey Dobriyan
	size-32: 3511 kvasprintf+0x57/0x90
	size-64: 3059 kobject_create+0x1c/0x40

These two buddies increase after every "modprobe; rmmod" sequence.

Do they also do so in mainline?

Yep, same bug in mainline.

Not good. Does 2.6.26 show this as well?

thanks,

greg k-h

#4 lore raw

PATCH 1/1 Fix "notes" kobject leak

Quoted 6 lines · Greg KH
Quoted 5 lines · Alexey Dobriyan
Quoted 4 lines · Greg KH
Quoted 3 lines · Alexey Dobriyan
	size-32: 3511 kvasprintf+0x57/0x90
	size-64: 3059 kobject_create+0x1c/0x40
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

These two buddies increase after every "modprobe; rmmod" sequence.

Do they also do so in mainline?

Yep, same bug in mainline.

Not good. Does 2.6.26 show this as well?

Uh-oh, this was actually 10-minute exercise.

[PATCH] Fix "notes" kobject leak

It happens every rmmod if KALLSYMS=y and SYSFS=y.

	# modprobe foo

kobject: 'foo' (ffffffffa00743d0): kobject_add_internal: parent: 'module', set: 'module'
kobject: 'holders' (ffff88017e7c5770): kobject_add_internal: parent: 'foo', set: '<NULL>'
kobject: 'foo' (ffffffffa00743d0): kobject_uevent_env
kobject: 'foo' (ffffffffa00743d0): fill_kobj_path: path = '/module/foo'
kobject: 'notes' (ffff88017fa9b668): kobject_add_internal: parent: 'foo', set: '<NULL>'

	  ^^^^^

	# rmmod foo

kobject: 'holders' (ffff88017e7c5770): kobject_cleanup
kobject: 'holders' (ffff88017e7c5770): auto cleanup kobject_del
kobject: 'holders' (ffff88017e7c5770): calling ktype release
kobject: (ffff88017e7c5770): dynamic_kobj_release
kobject: 'holders': free name
kobject: 'foo' (ffffffffa00743d0): kobject_cleanup
kobject: 'foo' (ffffffffa00743d0): does not have a release() function, it is broken and must be fixed.
kobject: 'foo' (ffffffffa00743d0): auto cleanup 'remove' event
kobject: 'foo' (ffffffffa00743d0): kobject_uevent_env
kobject: 'foo' (ffffffffa00743d0): fill_kobj_path: path = '/module/foo'
kobject: 'foo' (ffffffffa00743d0): auto cleanup kobject_del
kobject: 'foo': free name

[whooops]

---

 kernel/module.c |    1 +
 1 file changed, 1 insertion(+)
kernel/module.c +1 -0
@@ -1174,6 +1174,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
 			sysfs_remove_bin_file(notes_attrs->dir,
 					      &notes_attrs->attrs[i]);
 		kobject_del(notes_attrs->dir);
+		kobject_put(notes_attrs->dir);
 	}
 	kfree(notes_attrs);
 }
#5 lore raw

Re: [PATCH] Fix "notes" kobject leak

Quoted 58 lines · Alexey Dobriyan
Quoted 6 lines · Greg KH
Quoted 5 lines · Alexey Dobriyan
Quoted 4 lines · Greg KH
Quoted 3 lines · Alexey Dobriyan
	size-32: 3511 kvasprintf+0x57/0x90
	size-64: 3059 kobject_create+0x1c/0x40
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

These two buddies increase after every "modprobe; rmmod" sequence.

Do they also do so in mainline?

Yep, same bug in mainline.

Not good. Does 2.6.26 show this as well?

Uh-oh, this was actually 10-minute exercise.

[PATCH] Fix "notes" kobject leak

It happens every rmmod if KALLSYMS=y and SYSFS=y.

	# modprobe foo

kobject: 'foo' (ffffffffa00743d0): kobject_add_internal: parent: 'module', set: 'module'
kobject: 'holders' (ffff88017e7c5770): kobject_add_internal: parent: 'foo', set: '<NULL>'
kobject: 'foo' (ffffffffa00743d0): kobject_uevent_env
kobject: 'foo' (ffffffffa00743d0): fill_kobj_path: path = '/module/foo'
kobject: 'notes' (ffff88017fa9b668): kobject_add_internal: parent: 'foo', set: '<NULL>'

	  ^^^^^

	# rmmod foo

kobject: 'holders' (ffff88017e7c5770): kobject_cleanup
kobject: 'holders' (ffff88017e7c5770): auto cleanup kobject_del
kobject: 'holders' (ffff88017e7c5770): calling ktype release
kobject: (ffff88017e7c5770): dynamic_kobj_release
kobject: 'holders': free name
kobject: 'foo' (ffffffffa00743d0): kobject_cleanup
kobject: 'foo' (ffffffffa00743d0): does not have a release() function, it is broken and must be fixed.
kobject: 'foo' (ffffffffa00743d0): auto cleanup 'remove' event
kobject: 'foo' (ffffffffa00743d0): kobject_uevent_env
kobject: 'foo' (ffffffffa00743d0): fill_kobj_path: path = '/module/foo'
kobject: 'foo' (ffffffffa00743d0): auto cleanup kobject_del
kobject: 'foo': free name

[whooops]

---

 kernel/module.c |    1 +
 1 file changed, 1 insertion(+)

kernel/module.c static void free_notes_attrs(struct module_notes_attrs *notes_attrs, · line 1177

Quoted 4 lines
kernel/module.c +1 -0
@@ -1174,6 +1174,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
 			sysfs_remove_bin_file(notes_attrs->dir,
 					      &notes_attrs->attrs[i]);
 		kobject_del(notes_attrs->dir);
+		kobject_put(notes_attrs->dir);

Hm, no, that should just be a call to kobject_put() instead of kobject_del(), can you try that instead and see if that solves the issue (am at a conference and can't test that at the moment, sorry.)

thanks,

greg k-h

#6 lore raw

Re: [PATCH] Fix "notes" kobject leak

Quoted 56 lines · Greg KH
Quoted 55 lines · Alexey Dobriyan
Quoted 6 lines · Greg KH
Quoted 5 lines · Alexey Dobriyan
Quoted 4 lines · Greg KH
Quoted 3 lines · Alexey Dobriyan
	size-32: 3511 kvasprintf+0x57/0x90
	size-64: 3059 kobject_create+0x1c/0x40
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

These two buddies increase after every "modprobe; rmmod" sequence.

Do they also do so in mainline?

Yep, same bug in mainline.

Not good. Does 2.6.26 show this as well?

Uh-oh, this was actually 10-minute exercise.

[PATCH] Fix "notes" kobject leak

It happens every rmmod if KALLSYMS=y and SYSFS=y.

	# modprobe foo

kobject: 'foo' (ffffffffa00743d0): kobject_add_internal: parent: 'module', set: 'module'
kobject: 'holders' (ffff88017e7c5770): kobject_add_internal: parent: 'foo', set: '<NULL>'
kobject: 'foo' (ffffffffa00743d0): kobject_uevent_env
kobject: 'foo' (ffffffffa00743d0): fill_kobj_path: path = '/module/foo'
kobject: 'notes' (ffff88017fa9b668): kobject_add_internal: parent: 'foo', set: '<NULL>'

	  ^^^^^

	# rmmod foo

kobject: 'holders' (ffff88017e7c5770): kobject_cleanup
kobject: 'holders' (ffff88017e7c5770): auto cleanup kobject_del
kobject: 'holders' (ffff88017e7c5770): calling ktype release
kobject: (ffff88017e7c5770): dynamic_kobj_release
kobject: 'holders': free name
kobject: 'foo' (ffffffffa00743d0): kobject_cleanup
kobject: 'foo' (ffffffffa00743d0): does not have a release() function, it is broken and must be fixed.
kobject: 'foo' (ffffffffa00743d0): auto cleanup 'remove' event
kobject: 'foo' (ffffffffa00743d0): kobject_uevent_env
kobject: 'foo' (ffffffffa00743d0): fill_kobj_path: path = '/module/foo'
kobject: 'foo' (ffffffffa00743d0): auto cleanup kobject_del
kobject: 'foo': free name

[whooops]

---

 kernel/module.c |    1 +
 1 file changed, 1 insertion(+)
Quoted 11 lines

kernel/module.c static void free_notes_attrs(struct module_notes_attrs *notes_attrs, · line 1177

Quoted 7 lines
kernel/module.c +1 -0
@@ -1174,6 +1174,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
 			sysfs_remove_bin_file(notes_attrs->dir,
 					      &notes_attrs->attrs[i]);
 		kobject_del(notes_attrs->dir);
+		kobject_put(notes_attrs->dir);

Hm, no, that should just be a call to kobject_put() instead of kobject_del(), can you try that instead and see if that solves the issue (am at a conference and can't test that at the moment, sorry.)

Why?! kobject_del() puts parent kobject.

#7 lore raw

Re: [PATCH] Fix "notes" kobject leak

Quoted 69 lines · Alexey Dobriyan
Quoted 56 lines · Greg KH
Quoted 55 lines · Alexey Dobriyan
Quoted 6 lines · Greg KH
Quoted 5 lines · Alexey Dobriyan
Quoted 4 lines · Greg KH
Quoted 3 lines · Alexey Dobriyan
	size-32: 3511 kvasprintf+0x57/0x90
	size-64: 3059 kobject_create+0x1c/0x40
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

These two buddies increase after every "modprobe; rmmod" sequence.

Do they also do so in mainline?

Yep, same bug in mainline.

Not good. Does 2.6.26 show this as well?

Uh-oh, this was actually 10-minute exercise.

[PATCH] Fix "notes" kobject leak

It happens every rmmod if KALLSYMS=y and SYSFS=y.

	# modprobe foo

kobject: 'foo' (ffffffffa00743d0): kobject_add_internal: parent: 'module', set: 'module'
kobject: 'holders' (ffff88017e7c5770): kobject_add_internal: parent: 'foo', set: '<NULL>'
kobject: 'foo' (ffffffffa00743d0): kobject_uevent_env
kobject: 'foo' (ffffffffa00743d0): fill_kobj_path: path = '/module/foo'
kobject: 'notes' (ffff88017fa9b668): kobject_add_internal: parent: 'foo', set: '<NULL>'

	  ^^^^^

	# rmmod foo

kobject: 'holders' (ffff88017e7c5770): kobject_cleanup
kobject: 'holders' (ffff88017e7c5770): auto cleanup kobject_del
kobject: 'holders' (ffff88017e7c5770): calling ktype release
kobject: (ffff88017e7c5770): dynamic_kobj_release
kobject: 'holders': free name
kobject: 'foo' (ffffffffa00743d0): kobject_cleanup
kobject: 'foo' (ffffffffa00743d0): does not have a release() function, it is broken and must be fixed.
kobject: 'foo' (ffffffffa00743d0): auto cleanup 'remove' event
kobject: 'foo' (ffffffffa00743d0): kobject_uevent_env
kobject: 'foo' (ffffffffa00743d0): fill_kobj_path: path = '/module/foo'
kobject: 'foo' (ffffffffa00743d0): auto cleanup kobject_del
kobject: 'foo': free name

[whooops]

---

 kernel/module.c |    1 +
 1 file changed, 1 insertion(+)
Quoted 11 lines

kernel/module.c static void free_notes_attrs(struct module_notes_attrs *notes_attrs, · line 1177

Quoted 7 lines
kernel/module.c +1 -0
@@ -1174,6 +1174,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
 			sysfs_remove_bin_file(notes_attrs->dir,
 					      &notes_attrs->attrs[i]);
 		kobject_del(notes_attrs->dir);
+		kobject_put(notes_attrs->dir);

Hm, no, that should just be a call to kobject_put() instead of kobject_del(), can you try that instead and see if that solves the issue (am at a conference and can't test that at the moment, sorry.)

Quoted 1 line

Why?! kobject_del() puts parent kobject.

And that's about it (well, it also tears down the sysfs stuff.)

If you call kobject_put() instead, and it's the last put, it will also call kobject_del() and do everything else that it needs to do.

Try it and let me know if I'm right or not :)

thanks,

greg k-h

#8 lore raw

PATCH v2 1/1 Fix "notes" kobject leak

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines

kernel/module.c static void free_notes_attrs(struct module_notes_attrs *notes_attrs, · line 1177

Quoted 7 lines
kernel/module.c +1 -0
@@ -1174,6 +1174,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
 			sysfs_remove_bin_file(notes_attrs->dir,
 					      &notes_attrs->attrs[i]);
 		kobject_del(notes_attrs->dir);
+		kobject_put(notes_attrs->dir);

Hm, no, that should just be a call to kobject_put() instead of kobject_del(), can you try that instead and see if that solves the issue (am at a conference and can't test that at the moment, sorry.)

Quoted 8 lines
Quoted 1 line

Why?! kobject_del() puts parent kobject.

And that's about it (well, it also tears down the sysfs stuff.)

If you call kobject_put() instead, and it's the last put, it will also call kobject_del() and do everything else that it needs to do.

Try it and let me know if I'm right or not :)

OK, this works too.

[PATCH v2] Fix "notes" kobject leak

It happens every rmmod if KALLSYMS=y and SYSFS=y.

	# modprobe foo

kobject: 'foo' (ffffffffa00743d0): kobject_add_internal: parent: 'module', set: 'module'
kobject: 'holders' (ffff88017e7c5770): kobject_add_internal: parent: 'foo', set: '<NULL>'
kobject: 'foo' (ffffffffa00743d0): kobject_uevent_env
kobject: 'foo' (ffffffffa00743d0): fill_kobj_path: path = '/module/foo'
kobject: 'notes' (ffff88017fa9b668): kobject_add_internal: parent: 'foo', set: '<NULL>'

	  ^^^^^

	# rmmod foo

kobject: 'holders' (ffff88017e7c5770): kobject_cleanup
kobject: 'holders' (ffff88017e7c5770): auto cleanup kobject_del
kobject: 'holders' (ffff88017e7c5770): calling ktype release
kobject: (ffff88017e7c5770): dynamic_kobj_release
kobject: 'holders': free name
kobject: 'foo' (ffffffffa00743d0): kobject_cleanup
kobject: 'foo' (ffffffffa00743d0): does not have a release() function, it is broken and must be fixed.
kobject: 'foo' (ffffffffa00743d0): auto cleanup 'remove' event
kobject: 'foo' (ffffffffa00743d0): kobject_uevent_env
kobject: 'foo' (ffffffffa00743d0): fill_kobj_path: path = '/module/foo'
kobject: 'foo' (ffffffffa00743d0): auto cleanup kobject_del
kobject: 'foo': free name

[whooops]

---

 kernel/module.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/module.c +1 -1
@@ -1173,7 +1173,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
 		while (i-- > 0)
 			sysfs_remove_bin_file(notes_attrs->dir,
 					      &notes_attrs->attrs[i]);
-		kobject_del(notes_attrs->dir);
+		kobject_put(notes_attrs->dir);
 	}
 	kfree(notes_attrs);
 }
#9 lore raw

Re: [PATCH v2] Fix "notes" kobject leak

Quoted 19 lines · Alexey Dobriyan
Quoted 19 lines
Quoted 12 lines
Quoted 11 lines

kernel/module.c static void free_notes_attrs(struct module_notes_attrs *notes_attrs, · line 1177

Quoted 7 lines
kernel/module.c +1 -0
@@ -1174,6 +1174,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
 			sysfs_remove_bin_file(notes_attrs->dir,
 					      &notes_attrs->attrs[i]);
 		kobject_del(notes_attrs->dir);
+		kobject_put(notes_attrs->dir);

Hm, no, that should just be a call to kobject_put() instead of kobject_del(), can you try that instead and see if that solves the issue (am at a conference and can't test that at the moment, sorry.)

Quoted 1 line

Why?! kobject_del() puts parent kobject.

And that's about it (well, it also tears down the sysfs stuff.)

If you call kobject_put() instead, and it's the last put, it will also call kobject_del() and do everything else that it needs to do.

Quoted 6 lines
Quoted 1 line

Try it and let me know if I'm right or not :)

OK, this works too.

[PATCH v2] Fix "notes" kobject leak

Great, thanks for testing, I'll apply this to my trees.

greg k-h