sysfs: fix i_mutex locking in sysfs_get_dentry()
authorTejun Heo <htejun@gmail.com>
Mon, 20 Aug 2007 12:36:29 +0000 (21:36 +0900)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 12 Oct 2007 21:51:07 +0000 (14:51 -0700)
lookup_one_len_kern() should be called with the parent's i_mutex
locked.  Fix it.

Spotted by Eric W. Biederman.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/sysfs/dir.c

index a0da2b05a7545580ab152cae49098438edb3ac28..54ca4bc02dcfe73775bdb15f2ad3872573162f3a 100644 (file)
@@ -130,8 +130,10 @@ struct dentry *sysfs_get_dentry(struct sysfs_dirent *sd)
 
                /* look it up */
                parent_dentry = dentry;
+               mutex_lock(&parent_dentry->d_inode->i_mutex);
                dentry = lookup_one_len_kern(cur->s_name, parent_dentry,
                                             strlen(cur->s_name));
+               mutex_unlock(&parent_dentry->d_inode->i_mutex);
                dput(parent_dentry);
 
                if (IS_ERR(dentry)) {