Re: [PATCH 10/11] avoid kobject name conflict with different namespaces

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric W. Biederman
Date: Wednesday, May 7, 2008 - 11:49 am

Benjamin Thery <benjamin.thery@bull.net> writes:


Ok so we are dealing with fallout from:

commit 34358c26a2c96b2a068dc44e0ac602106a466bce
Author: Greg Kroah-Hartman <gregkh@suse.de>
Date:   Wed Oct 24 16:52:31 2007 -0700

    kobject: check for duplicate names in kobject_rename
    
    This should catch any duplicate names before we try to tell sysfs to
    rename the object.  This happens a lot with older versions of udev and
    the network rename scripts.
    
    Cc: David Miller <davem@davemloft.net>
    Cc: Kay Sievers <kay.sievers@vrfy.org>
    Cc: Rafael J. Wysocki <rjw@sisk.pl>
    Cc: Tejun Heo <htejun@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Which added the check in kobject_rename to prevent problems, and
seems to be causing a few.

I believe this earlier? patch addresses the problem:

commit c8d90dca3211966ba5189e0f3d4bccd558d9ae08
Author: Stephen Hemminger <shemminger@linux-foundation.org>
Date:   Fri Oct 26 03:53:42 2007 -0700

    [NET] dev_change_name: ignore changes to same name
    
    Prevent error/backtrace from dev_rename() when changing
    name of network device to the same name. This is a common
    situation with udev and other scripts that bind addr to device.
    
    Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>


And the challenge is that we are getting false positives in the check
to see if renames will fail.

	/* see if this name is already in use */
	if (kobj->kset) {
		struct kobject *temp_kobj;
		temp_kobj = kset_find_obj(kobj->kset, new_name);
		if (temp_kobj) {
			printk(KERN_WARNING "kobject '%s' can not be renamed 
				"to '%s' as '%s' is already in existance.\n",
				kobject_name(kobj), new_name, new_name);
			kobject_put(temp_kobj);
			return -EINVAL;
		}
	}

If the kobject layer wants to perform the test above how do we support
it by giving it enough information to perform the test without false
positives.

Certainly we can go to the sysfs layer but that has the problem
of being a layering violation and not working when sysfs is not
compiled in.  Ouch!


I believe what the sanity check should look like is:
	/* see if this name is already in use */
	if (kobj->kset) {
		struct kobject *temp_kobj;
*               void *tag;
*               tag = kobject_tag(kobj);
*		temp_kobj = kset_find_tagged_obj(kobj->kset, tag, new_name);
*		if (temp_kobj && (temp_kobj != kobj)) {
			printk(KERN_WARNING "kobject '%s' can not be renamed 
				"to '%s' as '%s' is already in existance.\n",
				kobject_name(kobj), new_name, new_name);
			kobject_put(temp_kobj);
			return -EINVAL;
		}
	}

The tricky part is how do we get to kobject_tag (from the
sysfs_tagged_dir_operations).

Unless there is another path I think placing an additional pointer in
kobj_type so we can find it through ktype is the simplest solution.
Although using the kset is also sane.

The easiest and most trivially correct thing to do would be to simply
remove the unnecessary check from kobject_rename.  We perform the
check at the upper levels in the network anyway.  And kobject_rename
is only used by the network stack.

....

As for the actual patch itself I have two nits to pick.


The new name should be compared with sysfs_creation_tag in
case we are dealing with the case of renaming across network
namespaces.    We could use sysfs_creation_tag for both as
the only time the dirent_tag and creation_tag should differ
is during a rename operation.


Either I am blind or this implementation breaks when we are using
kobjects and sysfs support is not compiled in.  It might be that
we don't do this work but still in principle this is a small bug.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 10/11] avoid kobject name conflict with differe ..., Eric W. Biederman, (Wed May 7, 11:49 am)
Re: [PATCH 10/11] avoid kobject name conflict with differe ..., Eric W. Biederman, (Thu May 8, 12:25 pm)
Re: [PATCH 10/11] avoid kobject name conflict with differe ..., Eric W. Biederman, (Thu May 8, 12:28 pm)
[PATCH] wireless: Add missing locking to cfg80211_dev_rename, Eric W. Biederman, (Thu May 8, 2:30 pm)
[PATCH] Fix kobject_rename and !CONFIG_SYSFS, Eric W. Biederman, (Thu May 8, 2:41 pm)
Re: [PATCH 10/11] avoid kobject name conflict with differe ..., Eric W. Biederman, (Fri May 9, 11:16 am)
Re: kobject: Fix kobject_rename and !CONFIG_SYSFS, Eric W. Biederman, (Tue May 13, 12:00 am)
Re: kobject: Fix kobject_rename and !CONFIG_SYSFS, Benjamin Thery, (Tue May 13, 7:25 am)
[PATCH] Fix kobject_rename and !CONFIG_SYSFS v2, Eric W. Biederman, (Tue May 13, 10:55 am)
Re: [PATCH] Fix kobject_rename and !CONFIG_SYSFS v2, Randy.Dunlap, (Tue May 13, 11:23 am)
Re: kobject: Fix kobject_rename and !CONFIG_SYSFS, Benjamin Thery , (Tue May 13, 12:33 pm)
Re: kobject: Fix kobject_rename and !CONFIG_SYSFS, Eric W. Biederman, (Tue May 13, 1:42 pm)
Re: [PATCH] Fix kobject_rename and !CONFIG_SYSFS v2, Eric W. Biederman, (Tue May 13, 1:43 pm)
[PATCH] Fix kobject_rename and !CONFIG_SYSFS v3, Eric W. Biederman, (Tue May 13, 1:45 pm)
Re: [PATCH] Fix kobject_rename and !CONFIG_SYSFS v3, Randy Dunlap, (Tue May 13, 2:18 pm)
[PATCH] Fix kobject_rename and !CONFIG_SYSFS v4, Eric W. Biederman, (Tue May 13, 9:39 pm)
Re: [PATCH] Fix kobject_rename and !CONFIG_SYSFS v4, Andrew Morton, (Tue May 13, 10:03 pm)
Re: [PATCH] Fix kobject_rename and !CONFIG_SYSFS v4, Eric W. Biederman, (Wed May 14, 2:01 am)
Re: [PATCH] Fix kobject_rename and !CONFIG_SYSFS v4, Andrew Morton, (Wed May 14, 2:20 am)
Re: [PATCH] Fix kobject_rename and !CONFIG_SYSFS v4, Benjamin Thery, (Wed May 14, 2:51 am)
Re: [PATCH] Fix kobject_rename and !CONFIG_SYSFS v4, Andrew Morton, (Wed May 14, 2:56 am)