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>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
89bec09705
commit
932ea2e374
@@ -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;
|
||||
|
Reference in New Issue
Block a user