From f55f75a191f661f652920f788501e6546a60c3f5 Mon Sep 17 00:00:00 2001 From: Tetsuo Handa Date: Thu, 8 Dec 2011 21:24:06 +0900 Subject: TOMOYO: Fix pathname handling of disconnected paths. commit 1418a3e5ad4d01b1d4abf2c479c50b0cedd59e3f upstream. Current tomoyo_realpath_from_path() implementation returns strange pathname when calculating pathname of a file which belongs to lazy unmounted tree. Use local pathname rather than strange absolute pathname in that case. Also, this patch fixes a regression by commit 02125a82 "fix apparmor dereferencing potentially freed dentry, sanitize __d_path() API". Signed-off-by: Tetsuo Handa Acked-by: Al Viro Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- security/tomoyo/realpath.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'security/tomoyo') diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c index b44dfde367ed..d46922db0540 100644 --- a/security/tomoyo/realpath.c +++ b/security/tomoyo/realpath.c @@ -275,8 +275,16 @@ char *tomoyo_realpath_from_path(struct path *path) pos = tomoyo_get_local_path(path->dentry, buf, buf_len - 1); /* Get absolute name for the rest. */ - else + else { pos = tomoyo_get_absolute_path(path, buf, buf_len - 1); + /* + * Fall back to local name if absolute name is not + * available. + */ + if (pos == ERR_PTR(-EINVAL)) + pos = tomoyo_get_local_path(path->dentry, buf, + buf_len - 1); + } encode: if (IS_ERR(pos)) continue; -- cgit v1.2.3