Commit 8b90e74d authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

mnt: don't match the wrong nested bind mount

Andrey reported this issue and it took me a while to figure out exactly what
might cause it. I think the comment describes it accurately, as with that
example I end up with mountinfo on the host like:

47 23 253:1 /root/bind1/subdir /root/bind2 rw,relatime shared:1 - ext4 /dev/disk/by-uuid/6c5a78e0-95fa-49a8-aa91-a8093d295e58 rw,data=ordered
48 23 253:1 /root/bind1 /root/bind3 rw,relatime shared:1 - ext4 /dev/disk/by-uuid/6c5a78e0-95fa-49a8-aa91-a8093d295e58 rw,data=ordered
Reported-by: 's avatarAndrew Vagin <avagin@odin.com>
CC: Andrew Vagin <avagin@odin.com>
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Acked-by: 's avatarAndrew Vagin <avagin@odin.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7e395cae
......@@ -674,6 +674,20 @@ static struct mount_info *find_best_external_match(struct mount_info *list, stru
if (!mounts_equal(info, it, true))
continue;
/*
* This means we have a situation like:
*
* root@criu:~# mount --bind bind1/subdir/ bind2
* root@criu:~# mount --bind bind1/ bind3
*
* outside the container, and bind1 is directly bind mounted
* inside the container. mounts_equal() considers these mounts
* equal for bind purposes, but their roots are different, and
* we want to match the one with the right root.
*/
if (!issubpath(info->root, it->root))
continue;
candidate = it;
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment