Skip to content

Commit

Permalink
sysfs: fix i_mutex locking in sysfs_get_dentry()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
htejun authored and gregkh committed Oct 12, 2007
1 parent 1359555 commit 2532802
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/sysfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 2532802

Please sign in to comment.