Skip to contentSkip to conversation

kobject: don't oops on null kobject.name

PATCH Chuck Ebbert 2 participants 2 messages Jan 14, 2006

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

In-Reply-To: <[email protected]>

Quoted 3 lines · Greg KH

Hm, I looked at the only user of kobjects in the kernel that I know of that doesn't use sysfs (the cdev code) and even it sets the kobject name to something sane, so I think we should be safe with this.

Well, something is still wrong.

I applied your patch to prevent registration of objects with null names on top of my patch, then applied this to see if my test still triggered, and the message was printed:

lib/kobject.c +3 -1
@@ -72,8 +72,10 @@ static int get_kobj_path_length(struct k
 	 * Add 1 to strlen for leading '/' of each level.
 	 */
 	do {
-		if (kobject_name(parent) == NULL)
+		if (kobject_name(parent) == NULL) {
+			printk("get_kobj_path_length: encountered NULL name\n");
 			return 0;
+		}
 		length += strlen(kobject_name(parent)) + 1;
 		parent = parent->parent;
 	} while (parent);

To reproduce:

Start with vanilla 2.6.15 and apply the three patches, which I called:

        kobject_dont_register_null_name.patch  <- my original
        kobject_handle_null_object_name.patch  <- Greg's
        kobject_debug_null_path.patch          <- included above

On a machine with an ATAPI CD-ROM, boot with "hdx=ide-scsi" where hdx is the CD-ROM's drivename. Then try to mount a CD:

mount -t iso9660 /dev/hdx /mnt/cdrom

Note that hdx is being controlled by ide-scsi so this should fail. You will see the message from my new patch print in the kernel log.

NOTE: This won't happen on 2.6.15-current because fs/super.c::kill_block_super() no longer calls kobject_uevent().

Signature · 2 lines
Chuck
Currently reading: _Olympos_ by Dan Simmons
#1 lore raw
Quoted 8 lines · Chuck Ebbert

In-Reply-To: <[email protected]>

Quoted 3 lines · Greg KH

Hm, I looked at the only user of kobjects in the kernel that I know of that doesn't use sysfs (the cdev code) and even it sets the kobject name to something sane, so I think we should be safe with this.

Quoted 5 lines

Well, something is still wrong.

I applied your patch to prevent registration of objects with null names on top of my patch, then applied this to see if my test still triggered, and the message was printed:

What was the message? What traceback?

So, I think the point is that it isn't a kobject_add() issue, right?

Quoted 29 lines
lib/kobject.c +3 -1
@@ -72,8 +72,10 @@ static int get_kobj_path_length(struct k
 	 * Add 1 to strlen for leading '/' of each level.
 	 */
 	do {
-		if (kobject_name(parent) == NULL)
+		if (kobject_name(parent) == NULL) {
+			printk("get_kobj_path_length: encountered NULL name\n");
 			return 0;
+		}
 		length += strlen(kobject_name(parent)) + 1;
 		parent = parent->parent;
 	} while (parent);

To reproduce:

Start with vanilla 2.6.15 and apply the three patches, which I called:

        kobject_dont_register_null_name.patch  <- my original
        kobject_handle_null_object_name.patch  <- Greg's
        kobject_debug_null_path.patch          <- included above

On a machine with an ATAPI CD-ROM, boot with "hdx=ide-scsi" where hdx is the CD-ROM's drivename. Then try to mount a CD:

Quoted 7 lines

mount -t iso9660 /dev/hdx /mnt/cdrom

Note that hdx is being controlled by ide-scsi so this should fail. You will see the message from my new patch print in the kernel log.

NOTE: This won't happen on 2.6.15-current because fs/super.c::kill_block_super() no longer calls kobject_uevent().

So everything's fixed and we don't have to worry about it anymore :)

Seriously, I agree, we still need to fix it for -stable.

thanks,

greg k-h