[Devel] [PATCH RHEL7 COMMIT] ms/root dentries need RCU-delayed freeing

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jul 1 12:37:19 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.21.3.vz7.106.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.21.3.vz7.106.3
------>
commit 70415a70e876a7d74ba0884acae04d5737382da0
Author: Al Viro <viro at zeniv.linux.org.uk>
Date:   Mon Jul 1 12:37:16 2019 +0300

    ms/root dentries need RCU-delayed freeing
    
    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 at vger.kernel.org
    Signed-off-by: Al Viro <viro at zeniv.linux.org.uk>
    (cherry picked from commit 90bad5e05bcdb0308cfa3d3a60f5c0b9c8e2efb3)
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 fs/dcache.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 162ac36ae74f..9053ee03397b 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1882,10 +1882,12 @@ struct dentry *d_make_root(struct inode *root_inode)
 		static const struct qstr name = QSTR_INIT("/", 1);
 
 		res = __d_alloc(root_inode->i_sb, &name);
-		if (res)
+		if (res) {
+			res->d_flags |= DCACHE_RCUACCESS;
 			d_instantiate(res, root_inode);
-		else
+		} else {
 			iput(root_inode);
+		}
 	}
 	return res;
 }



More information about the Devel mailing list