From: Tejun Heo Date: Mon, 20 Aug 2007 12:36:29 +0000 (+0900) Subject: sysfs: fix i_mutex locking in sysfs_get_dentry() X-Git-Tag: firefly_0821_release~26010^2~37 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=253280267a7f1ced0c434fb24b7bef92d7d22628;p=firefly-linux-kernel-4.4.55.git sysfs: fix i_mutex locking in sysfs_get_dentry() 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 Cc: Eric W. Biederman Cc: Cornelia Huck Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index a0da2b05a754..54ca4bc02dcf 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -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)) {