[CRIU] [PATCH] mount: handle a circular reference in mount tree

Andrey Vagin avagin at openvz.org
Fri Sep 12 04:41:00 PDT 2014


$ cat /proc/self/mountinfo
...
1 1 0:2 / / rw - rootfs rootfs rw,size=373396k,nr_inodes=93349
...

You can see that mnt_id and parent_mnt_id are equals here.
This patch interpretes this case as a root mount in a tree.

Cc: beproject criu <beprojectcriu at gmail.com>
Cc: Christopher Covington <cov at codeaurora.org>
Reported-by: beproject criu <beprojectcriu at gmail.com>
Reviewed-by: Christopher Covington <cov at codeaurora.org>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 mount.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/mount.c b/mount.c
index bf27052..0509ee3 100644
--- a/mount.c
+++ b/mount.c
@@ -251,7 +251,12 @@ static struct mount_info *mnt_build_ids_tree(struct mount_info *list)
 		struct mount_info *p;
 
 		pr_debug("\t\tWorking on %d->%d\n", m->mnt_id, m->parent_mnt_id);
-		p = __lookup_mnt_id(list, m->parent_mnt_id);
+
+		if (m->mnt_id != m->parent_mnt_id)
+			p = __lookup_mnt_id(list, m->parent_mnt_id);
+		else /* a circular mount reference. It's rootfs or smth like it. */
+			p = NULL;
+
 		if (!p) {
 			/* This should be / */
 			if (root == NULL && is_root_mount(m)) {
-- 
1.9.3



More information about the CRIU mailing list