Commit f167a1dd authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Andrei Vagin

mount: add helper to check unsupported children collision

See more detailed explanation inside in-code comment.

note: Actually before we remove validate_mounts (later in these
patchset) we likely won't get to these check and fail earlier, as having
children collision implies shared mounts with different sets of
children.

note: from v4.11 and ms kernel commit 1064f874abc0 ("mnt: Tuck mounts
under others instead of creating shadow/side mounts.") there will be no
more mount collision.
Signed-off-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
parent 35fbc373
......@@ -685,6 +685,34 @@ static bool mnt_is_external(struct mount_info *m)
return 0;
}
/*
* Having two children whith same mountpoint is unsupported. That can happen in
* case of mount propagation inside of shared mounts, in that case it is hard
* to find out mount propagation siblings and which of these mounts is above
* (visible) and which is beneath (hidden). It would've broken mount restore
* order in can_mount_now and also visibility assumptions in open_mountpoint.
*
* Anyway after kernel v4.11 such mounts will be impossible.
*/
static int validate_children_collision(struct mount_info *mnt)
{
struct mount_info *chi, *chj;
list_for_each_entry(chi, &mnt->children, siblings) {
list_for_each_entry(chj, &mnt->children, siblings) {
if (chj == chi)
break;
if (!strcmp(chj->mountpoint, chi->mountpoint)) {
pr_err("Mount %d has two children with same "
"mountpoint: %d %d\n",
mnt->mnt_id, chj->mnt_id, chi->mnt_id);
return -1;
}
}
}
return 0;
}
static int validate_mounts(struct mount_info *info, bool for_dump)
{
struct mount_info *m, *t;
......@@ -697,6 +725,9 @@ static int validate_mounts(struct mount_info *info, bool for_dump)
if (m->shared_id && validate_shared(m))
return -1;
if (validate_children_collision(m))
return -1;
if (mnt_is_external(m))
continue;
......
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