]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
root dentries need RCU-delayed freeing
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 6 Aug 2018 13:03:58 +0000 (09:03 -0400)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:42:00 +0000 (19:42 -0600)
BugLink: https://bugs.launchpad.net/bugs/1835845
commit 90bad5e05bcdb0308cfa3d3a60f5c0b9c8e2efb3 upstream.

Since mountpoint crossing can happen without leaving lazy mode,
root dentries do need the same protection against having their
memory freed without RCU delay as everything else in the tree.

It's partially hidden by RCU delay between detaching from the
mount tree and dropping the vfsmount reference, but the starting
point of pathwalk can be on an already detached mount, in which
case umount-caused RCU delay has already passed by the time the
lazy pathwalk grabs rcu_read_lock().  If the starting point
happens to be at the root of that vfsmount *and* that vfsmount
covers the entire filesystem, we get trouble.

Fixes: 48a066e72d97 ("RCU'd vsfmounts")
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/dcache.c

index ca3129bfe1089a7d71cded900fc04f6354d2fcaf..6721345fa3037d733e1726e98a6f129db7433ada 100644 (file)
@@ -1923,10 +1923,12 @@ struct dentry *d_make_root(struct inode *root_inode)
 
        if (root_inode) {
                res = __d_alloc(root_inode->i_sb, NULL);
-               if (res)
+               if (res) {
+                       res->d_flags |= DCACHE_RCUACCESS;
                        d_instantiate(res, root_inode);
-               else
+               } else {
                        iput(root_inode);
+               }
        }
        return res;
 }