• Andrey Vagin's avatar
    mntns: rework validation to support non-root shared bind-mounts (v2) · 1cf5168c
    Andrey Vagin authored
    A problem which is solved in this path is that some children can be
    unaccessiable (unvisiable) for non-root bind-mounts
    
    root	mount point
    -------------------
    /	/a (shared:1)
    /	/a/x
    /	/a/x/y
    /	/a/z
    /x	/b (shared:1)
    /	/b/y
    
    /b is a non-root bind-mount of /a
    /y is visiable to both mounts
    /z is vidiable only for /a
    
    Before this patch we checked that the set of children is the same for
    all mount in a shared group. Now we check that a visiable set of mounts
    is the same for all mounts in a shared group.
    
    Now we take the next mount in the shared group, which is wider or equal
    to current and compare children between them.
    
    Before this patch validate_shared(m) validates the m->parent mount.
    Now it validates the "m" mount. So you can find following lines in the
    patch:
    -               if (m->parent->shared_id && validate_shared(m))
    +               if (m->shared_id && validate_shared(m))
    
    We doesn't support shared mounts with different set of children.
    Here is an example of such case can be created:
    mount tmpfs a /a
    mount --make-shared /a
    mkdir /a/b
    mount tmpfs b /a/b
    mount --bind /a /c
    
    In this case /c doesn't have the /b child. To support such cases,
    we need to sort all shared mounts accoding with a set of children.
    
    v2: If root is equal to "/", its len should be zero. We expect that the
    last symbol in a path is not "/".
    Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
    1cf5168c
mount.c 49.2 KB