Skip to content

Commit 8cb7104

Browse files
committed
Merge tag 'configfs-for-5.2-2' of git://git.infradead.org/users/hch/configfs
Pull configs fix from Christoph Hellwig: - fix a use after free in configfs_d_iput (Sahitya Tummala) * tag 'configfs-for-5.2-2' of git://git.infradead.org/users/hch/configfs: configfs: Fix use-after-free when accessing sd->s_dentry
2 parents c5ba171 + f6122ed commit 8cb7104

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

fs/configfs/dir.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,13 @@ static void configfs_d_iput(struct dentry * dentry,
5858
if (sd) {
5959
/* Coordinate with configfs_readdir */
6060
spin_lock(&configfs_dirent_lock);
61-
/* Coordinate with configfs_attach_attr where will increase
62-
* sd->s_count and update sd->s_dentry to new allocated one.
63-
* Only set sd->dentry to null when this dentry is the only
64-
* sd owner.
65-
* If not do so, configfs_d_iput may run just after
66-
* configfs_attach_attr and set sd->s_dentry to null
67-
* even it's still in use.
61+
/*
62+
* Set sd->s_dentry to null only when this dentry is the one
63+
* that is going to be killed. Otherwise configfs_d_iput may
64+
* run just after configfs_attach_attr and set sd->s_dentry to
65+
* NULL even it's still in use.
6866
*/
69-
if (atomic_read(&sd->s_count) <= 2)
67+
if (sd->s_dentry == dentry)
7068
sd->s_dentry = NULL;
7169

7270
spin_unlock(&configfs_dirent_lock);

0 commit comments

Comments
 (0)