Commit 8cb7104d authored by Linus Torvalds's avatar Linus Torvalds

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
parents c5ba1712 f6122ed2
...@@ -58,15 +58,13 @@ static void configfs_d_iput(struct dentry * dentry, ...@@ -58,15 +58,13 @@ static void configfs_d_iput(struct dentry * dentry,
if (sd) { if (sd) {
/* Coordinate with configfs_readdir */ /* Coordinate with configfs_readdir */
spin_lock(&configfs_dirent_lock); spin_lock(&configfs_dirent_lock);
/* Coordinate with configfs_attach_attr where will increase /*
* sd->s_count and update sd->s_dentry to new allocated one. * Set sd->s_dentry to null only when this dentry is the one
* Only set sd->dentry to null when this dentry is the only * that is going to be killed. Otherwise configfs_d_iput may
* sd owner. * run just after configfs_attach_attr and set sd->s_dentry to
* If not do so, configfs_d_iput may run just after * NULL even it's still in use.
* configfs_attach_attr and set sd->s_dentry to null
* even it's still in use.
*/ */
if (atomic_read(&sd->s_count) <= 2) if (sd->s_dentry == dentry)
sd->s_dentry = NULL; sd->s_dentry = NULL;
spin_unlock(&configfs_dirent_lock); spin_unlock(&configfs_dirent_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment