[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20080506173335.922289888@theryb.frec.bull.fr>
Date: Tue, 06 May 2008 19:32:10 +0200
From: Benjamin Thery <benjamin.thery@...l.net>
To: linux-kernel@...r.kernel.org
Cc: "Eric W. Biederman" <ebiederm@...ssion.com>,
Tejun Heo <htejun@...il.com>,
Greg Kroah-Hartman <gregkh@...e.de>,
Al Viro <viro@....linux.org.uk>,
Daniel Lezcano <dlezcano@...ibm.com>,
"Serge E. Hallyn" <serue@...ibm.com>,
Pavel Emelyanov <xemul@...nvz.org>, netdev@...r.kernel.org,
Benjamin Thery <benjamin.thery@...l.net>
Subject: [PATCH 10/11] avoid kobject name conflict with different namespaces
The renaming of a kobject will fail if there is another kobject
with the same name belonging to another namespace.
This patch makes the kobject lookup in kobject_rename to check if
the object exists _and_ belongs to the same namespace.
Signed-off-by: Daniel Lezcano <dlezcano@...ibm.com>
Acked-by: Benjamin Thery <benjamin.thery@...l.net>
---
fs/sysfs/dir.c | 10 ++++++++++
include/linux/sysfs.h | 7 +++++++
lib/kobject.c | 2 +-
3 files changed, 18 insertions(+), 1 deletion(-)
Index: linux-vanilla/fs/sysfs/dir.c
===================================================================
--- linux-vanilla.orig/fs/sysfs/dir.c
+++ linux-vanilla/fs/sysfs/dir.c
@@ -902,6 +902,16 @@ err_out:
return error;
}
+int sysfs_tag_cmp(struct kobject *kobj1, struct kobject *kobj2)
+{
+ struct sysfs_dirent *sd1 = kobj1->sd;
+ struct sysfs_dirent *sd2 = kobj2->sd;
+ const void *tag1 = sysfs_dirent_tag(sd1);
+ const void *tag2 = sysfs_dirent_tag(sd2);
+
+ return tag1 != tag2;
+}
+
int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
{
struct sysfs_dirent *sd = kobj->sd;
Index: linux-vanilla/include/linux/sysfs.h
===================================================================
--- linux-vanilla.orig/include/linux/sysfs.h
+++ linux-vanilla/include/linux/sysfs.h
@@ -95,6 +95,8 @@ int sysfs_schedule_callback(struct kobje
int __must_check sysfs_create_dir(struct kobject *kobj);
void sysfs_remove_dir(struct kobject *kobj);
+int sysfs_tag_cmp(struct kobject *kobj1, struct kobject *kobj2);
+
int __must_check sysfs_rename_dir(struct kobject *kobj, const char *new_name);
int __must_check sysfs_move_dir(struct kobject *kobj,
struct kobject *new_parent_kobj);
@@ -154,6 +156,11 @@ static inline void sysfs_remove_dir(stru
{
}
+static inline int sysfs_tag_cmp(struct kobject *kobj1, struct kobject *kobj2)
+{
+ return 0;
+}
+
static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name)
{
return 0;
Index: linux-vanilla/lib/kobject.c
===================================================================
--- linux-vanilla.orig/lib/kobject.c
+++ linux-vanilla/lib/kobject.c
@@ -401,7 +401,7 @@ int kobject_rename(struct kobject *kobj,
if (kobj->kset) {
struct kobject *temp_kobj;
temp_kobj = kset_find_obj(kobj->kset, new_name);
- if (temp_kobj) {
+ if (temp_kobj && !sysfs_tag_cmp(temp_kobj, kobj)) {
printk(KERN_WARNING "kobject '%s' cannot be renamed "
"to '%s' as '%s' is already in existence.\n",
kobject_name(kobj), new_name, new_name);
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists