aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
Diffstat (limited to 'security')
-rw-r--r--security/tomoyo/realpath.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c
index 18369d497eb8..6a4f8495f281 100644
--- a/security/tomoyo/realpath.c
+++ b/security/tomoyo/realpath.c
@@ -89,27 +89,12 @@ int tomoyo_realpath_from_path2(struct path *path, char *newname,
89 sp = dentry->d_op->d_dname(dentry, newname + offset, 89 sp = dentry->d_op->d_dname(dentry, newname + offset,
90 newname_len - offset); 90 newname_len - offset);
91 } else { 91 } else {
92 /* Taken from d_namespace_path(). */ 92 struct path ns_root = {.mnt = NULL, .dentry = NULL};
93 struct path root; 93
94 struct path ns_root = { };
95 struct path tmp;
96
97 read_lock(&current->fs->lock);
98 root = current->fs->root;
99 path_get(&root);
100 read_unlock(&current->fs->lock);
101 spin_lock(&vfsmount_lock);
102 if (root.mnt && root.mnt->mnt_ns)
103 ns_root.mnt = mntget(root.mnt->mnt_ns->root);
104 if (ns_root.mnt)
105 ns_root.dentry = dget(ns_root.mnt->mnt_root);
106 spin_unlock(&vfsmount_lock);
107 spin_lock(&dcache_lock); 94 spin_lock(&dcache_lock);
108 tmp = ns_root; 95 /* go to whatever namespace root we are under */
109 sp = __d_path(path, &tmp, newname, newname_len); 96 sp = __d_path(path, &ns_root, newname, newname_len);
110 spin_unlock(&dcache_lock); 97 spin_unlock(&dcache_lock);
111 path_put(&root);
112 path_put(&ns_root);
113 /* Prepend "/proc" prefix if using internal proc vfs mount. */ 98 /* Prepend "/proc" prefix if using internal proc vfs mount. */
114 if (!IS_ERR(sp) && (path->mnt->mnt_parent == path->mnt) && 99 if (!IS_ERR(sp) && (path->mnt->mnt_parent == path->mnt) &&
115 (strcmp(path->mnt->mnt_sb->s_type->name, "proc") == 0)) { 100 (strcmp(path->mnt->mnt_sb->s_type->name, "proc") == 0)) {