diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-08-20 21:36:30 +0900 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-12 14:51:08 -0700 |
commit | 932ea2e374dd1ca26676297a5eccd1cdab86f7cd (patch) | |
tree | 83bba794de7f1f9f9290192f4f95a8ed9c91dfb6 /fs/sysfs/file.c | |
parent | 89bec09705d2033b8b765f3c3ac5093f80bd5bc4 (diff) | |
download | op-kernel-dev-932ea2e374dd1ca26676297a5eccd1cdab86f7cd.zip op-kernel-dev-932ea2e374dd1ca26676297a5eccd1cdab86f7cd.tar.gz |
sysfs: Introduce sysfs_rename_mutex
Looking carefully at the rename code we have a subtle dependency
that the structure of sysfs not change while we are performing
a rename. If the parent directory of the object we are renaming
changes while the rename is being performed nasty things could
happen when we go to release our locks.
So introduce a sysfs_rename_mutex to prevent this highly
unlikely theoretical issue.
In addition hold sysfs_rename_mutex over all calls to
sysfs_get_dentry. Allowing sysfs_get_dentry to be simplified
in the future.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r-- | fs/sysfs/file.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 16f39c3..ff93c92 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -470,7 +470,9 @@ int sysfs_update_file(struct kobject * kobj, const struct attribute * attr) if (!victim_sd) goto out; + mutex_lock(&sysfs_rename_mutex); victim = sysfs_get_dentry(victim_sd); + mutex_unlock(&sysfs_rename_mutex); if (IS_ERR(victim)) { rc = PTR_ERR(victim); victim = NULL; @@ -509,7 +511,9 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) if (!victim_sd) goto out; + mutex_lock(&sysfs_rename_mutex); victim = sysfs_get_dentry(victim_sd); + mutex_unlock(&sysfs_rename_mutex); if (IS_ERR(victim)) { rc = PTR_ERR(victim); victim = NULL; |