mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
mnt: Fix validation of dumpable mountpoints
This patch consists of 3 unsplittable (from my POV) fixes. 1. Remove messy check from dump_one_mountpoint() -- we have validate_mounts to check whether we can dump the tree or not. 2. Other than being in the wron place the mentioned check is wrong. Comparing of the length of the mp->source-s makes no sense -- it should be mp->root, but even this would be wrong... 3. ... instead, we should check for bind mount root path being accessible from the target mount root path, i.e. the bind->root should start with src->root. Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Acked-by: Andrew Vagin <avagin@parallels.com>
This commit is contained in:
parent
3635f2c4b9
commit
30e95be264
42
mount.c
42
mount.c
@ -313,7 +313,7 @@ static int validate_mounts(struct mount_info *info, bool call_plugins)
|
|||||||
struct mount_info *m, *t;
|
struct mount_info *m, *t;
|
||||||
|
|
||||||
for (m = info; m; m = m->next) {
|
for (m = info; m; m = m->next) {
|
||||||
if (m->parent == NULL)
|
if (m->parent == NULL || m->is_ns_root)
|
||||||
/* root mount can be any */
|
/* root mount can be any */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -337,11 +337,31 @@ static int validate_mounts(struct mount_info *info, bool call_plugins)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fsroot_mounted(m)) {
|
/*
|
||||||
|
* Mountpoint can point to / of an FS. In that case this FS
|
||||||
|
* should be of some known type so that we can just mount one.
|
||||||
|
*
|
||||||
|
* Otherwise it's a bindmount mountpoint and we try to find
|
||||||
|
* what fsroot mountpoint it's bound to. If this point is the
|
||||||
|
* root mount, the path to bindmount root should be accessible
|
||||||
|
* form the rootmount path (the strstartswith check in the
|
||||||
|
* else branch below).
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (fsroot_mounted(m)) {
|
||||||
|
if (m->fstype->code == FSTYPE__UNSUPPORTED) {
|
||||||
|
pr_err("FS mnt %s dev %#x root %s unsupported id %x\n",
|
||||||
|
m->mountpoint, m->s_dev, m->root, m->mnt_id);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
list_for_each_entry(t, &m->mnt_bind, mnt_bind) {
|
list_for_each_entry(t, &m->mnt_bind, mnt_bind) {
|
||||||
if (fsroot_mounted(t) || t->parent == NULL)
|
if (fsroot_mounted(t) ||
|
||||||
|
(t->parent == NULL &&
|
||||||
|
strstartswith(m->root, t->root)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (&t->mnt_bind == &m->mnt_bind) {
|
if (&t->mnt_bind == &m->mnt_bind) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -783,22 +803,6 @@ static int dump_one_mountpoint(struct mount_info *pm, int fd)
|
|||||||
pm->root, pm->mountpoint);
|
pm->root, pm->mountpoint);
|
||||||
|
|
||||||
me.fstype = pm->fstype->code;
|
me.fstype = pm->fstype->code;
|
||||||
if ((me.fstype == FSTYPE__UNSUPPORTED) && !is_root_mount(pm)) {
|
|
||||||
struct mount_info *t;
|
|
||||||
|
|
||||||
/* Is it a bind-mount of the root mount */
|
|
||||||
list_for_each_entry(t, &pm->mnt_bind, mnt_bind)
|
|
||||||
if (t->parent == NULL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (&t->mnt_bind == &pm->mnt_bind ||
|
|
||||||
strlen(t->source) > strlen(pm->source)) {
|
|
||||||
pr_err("FS mnt %s dev %#x root %s unsupported\n",
|
|
||||||
pm->mountpoint, pm->s_dev, pm->root);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pm->need_plugin && pm->fstype->dump && pm->fstype->dump(pm))
|
if (!pm->need_plugin && pm->fstype->dump && pm->fstype->dump(pm))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user