[CRIU] [PATCH] sk-unix: Fix name resolving on nested mount points

Cyrill Gorcunov gorcunov at openvz.org
Thu Jul 30 12:53:48 PDT 2015


In case if socket's cwd lays on nested mount point
we might resolve its path a bit incorrectly
(mount_resolve_path helper should not obtain
 paths with leading dot).

Thus send a path without leading dot for correct
name resolving.

Also add some error messages.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 sk-unix.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sk-unix.c b/sk-unix.c
index 75513e5725cb..7a9972864e6e 100644
--- a/sk-unix.c
+++ b/sk-unix.c
@@ -188,16 +188,22 @@ static int resolve_rel_name(struct unix_sk_desc *sk, const struct fd_parms *p)
 		if (task->pid.real == p->pid)
 			break;
 	}
-	if (!task)
+	if (!task) {
+		pr_err("Can't find task with pid %d\n", p->pid);
 		return -ENOENT;
+	}
 
 	ns = lookup_ns_by_id(task->ids->mnt_ns_id, &mnt_ns_desc);
-	if (!ns)
+	if (!ns) {
+		pr_err("Can't resolve mount namespace for pid %d\n", p->pid);
 		return -ENOENT;
+	}
 
 	mntns_root = mntns_get_root_fd(ns);
-	if (mntns_root < 0)
+	if (mntns_root < 0) {
+		pr_err("Can't resolve fs root for pid %d\n", p->pid);
 		return -ENOENT;
+	}
 
 	pr_debug("Resolving relative name %s for socket %x\n",
 		 sk->name, sk->sd.ino);
@@ -223,7 +229,7 @@ static int resolve_rel_name(struct unix_sk_desc *sk, const struct fd_parms *p)
 		}
 
 		if ((st.st_ino == rel_name->udiag_vfs_ino) &&
-		    phys_stat_dev_match(st.st_dev, rel_name->udiag_vfs_dev, ns, path)) {
+		    phys_stat_dev_match(st.st_dev, rel_name->udiag_vfs_dev, ns, &path[1])) {
 			rel_name->dir = xstrdup(dir);
 			if (!rel_name->dir)
 				return -ENOMEM;
-- 
2.4.3



More information about the CRIU mailing list