[CRIU] [PATCH] mnt: don't match the wrong nested bind mount
Andrew Vagin
avagin at odin.com
Wed Apr 15 08:12:59 PDT 2015
On Wed, Apr 15, 2015 at 09:00:37AM -0600, Tycho Andersen wrote:
> 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: Andrew Vagin <avagin at odin.com>
> CC: Andrew Vagin <avagin at odin.com>
Acked-by: Andrew Vagin <avagin at odin.com>
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> ---
> mount.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/mount.c b/mount.c
> index 1bb2ebc..b47041d 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -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 at criu:~# mount --bind bind1/subdir/ bind2
> + * root at 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;
>
> /*
> --
> 2.1.4
>
More information about the CRIU
mailing list