diff options
Diffstat (limited to 'security/tomoyo/realpath.c')
-rw-r--r-- | security/tomoyo/realpath.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c index c00df45c7ede..cf7d61f781b9 100644 --- a/security/tomoyo/realpath.c +++ b/security/tomoyo/realpath.c | |||
@@ -88,29 +88,14 @@ int tomoyo_realpath_from_path2(struct path *path, char *newname, | |||
88 | sp = dentry->d_op->d_dname(dentry, newname + offset, | 88 | sp = dentry->d_op->d_dname(dentry, newname + offset, |
89 | newname_len - offset); | 89 | newname_len - offset); |
90 | } else { | 90 | } else { |
91 | /* Taken from d_namespace_path(). */ | 91 | struct path ns_root = {.mnt = NULL, .dentry = NULL}; |
92 | struct path root; | ||
93 | struct path ns_root = { }; | ||
94 | struct path tmp; | ||
95 | 92 | ||
96 | read_lock(¤t->fs->lock); | ||
97 | root = current->fs->root; | ||
98 | path_get(&root); | ||
99 | read_unlock(¤t->fs->lock); | ||
100 | spin_lock(&vfsmount_lock); | ||
101 | if (root.mnt && root.mnt->mnt_ns) | ||
102 | ns_root.mnt = mntget(root.mnt->mnt_ns->root); | ||
103 | if (ns_root.mnt) | ||
104 | ns_root.dentry = dget(ns_root.mnt->mnt_root); | ||
105 | spin_unlock(&vfsmount_lock); | ||
106 | spin_lock(&dcache_lock); | 93 | spin_lock(&dcache_lock); |
107 | tmp = ns_root; | 94 | /* go to whatever namespace root we are under */ |
108 | sp = __d_path(path, &tmp, newname, newname_len); | 95 | sp = __d_path(path, &ns_root, newname, newname_len); |
109 | spin_unlock(&dcache_lock); | 96 | spin_unlock(&dcache_lock); |
110 | path_put(&root); | ||
111 | path_put(&ns_root); | ||
112 | /* Prepend "/proc" prefix if using internal proc vfs mount. */ | 97 | /* Prepend "/proc" prefix if using internal proc vfs mount. */ |
113 | if (!IS_ERR(sp) && (path->mnt->mnt_parent == path->mnt) && | 98 | if (!IS_ERR(sp) && (path->mnt->mnt_flags & MNT_INTERNAL) && |
114 | (path->mnt->mnt_sb->s_magic == PROC_SUPER_MAGIC)) { | 99 | (path->mnt->mnt_sb->s_magic == PROC_SUPER_MAGIC)) { |
115 | sp -= 5; | 100 | sp -= 5; |
116 | if (sp >= newname) | 101 | if (sp >= newname) |