aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/realpath.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/tomoyo/realpath.c')
-rw-r--r--security/tomoyo/realpath.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c
index 738bbdf8d4c7..d9f3ced8756e 100644
--- a/security/tomoyo/realpath.c
+++ b/security/tomoyo/realpath.c
@@ -101,9 +101,8 @@ static char *tomoyo_get_absolute_path(struct path *path, char * const buffer,
101{ 101{
102 char *pos = ERR_PTR(-ENOMEM); 102 char *pos = ERR_PTR(-ENOMEM);
103 if (buflen >= 256) { 103 if (buflen >= 256) {
104 struct path ns_root = { };
105 /* go to whatever namespace root we are under */ 104 /* go to whatever namespace root we are under */
106 pos = __d_path(path, &ns_root, buffer, buflen - 1); 105 pos = d_absolute_path(path, buffer, buflen - 1);
107 if (!IS_ERR(pos) && *pos == '/' && pos[1]) { 106 if (!IS_ERR(pos) && *pos == '/' && pos[1]) {
108 struct inode *inode = path->dentry->d_inode; 107 struct inode *inode = path->dentry->d_inode;
109 if (inode && S_ISDIR(inode->i_mode)) { 108 if (inode && S_ISDIR(inode->i_mode)) {
@@ -294,8 +293,16 @@ char *tomoyo_realpath_from_path(struct path *path)
294 pos = tomoyo_get_local_path(path->dentry, buf, 293 pos = tomoyo_get_local_path(path->dentry, buf,
295 buf_len - 1); 294 buf_len - 1);
296 /* Get absolute name for the rest. */ 295 /* Get absolute name for the rest. */
297 else 296 else {
298 pos = tomoyo_get_absolute_path(path, buf, buf_len - 1); 297 pos = tomoyo_get_absolute_path(path, buf, buf_len - 1);
298 /*
299 * Fall back to local name if absolute name is not
300 * available.
301 */
302 if (pos == ERR_PTR(-EINVAL))
303 pos = tomoyo_get_local_path(path->dentry, buf,
304 buf_len - 1);
305 }
299encode: 306encode:
300 if (IS_ERR(pos)) 307 if (IS_ERR(pos))
301 continue; 308 continue;