2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 01:51:51 +00:00

mount: restore root mount flags

Mount flags belong to mount and mount namespace of the Container, so we
should preserve them, as Container user will not expect mounts switching
between ro and rw over c/r.

Fixes: #2632

v5: fix both mount-v1 and mount-v2

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
Andrei Vagin 2025-04-02 12:02:46 +08:00
parent 799504d9ff
commit 6a91ad8f71
2 changed files with 13 additions and 0 deletions

View File

@ -443,6 +443,7 @@ err:
/* Mounts root container mount. */
static int do_mount_root_v2(struct mount_info *mi)
{
unsigned long mflags = mi->flags & (~MS_PROPAGATE);
unsigned long flags = MS_BIND;
int fd;
@ -477,6 +478,11 @@ static int do_mount_root_v2(struct mount_info *mi)
return -1;
}
if (mflags && mount(NULL, mi->plain_mountpoint, NULL, MS_REMOUNT | MS_BIND | mflags, NULL)) {
pr_perror("Unable to apply root mount options");
return -1;
}
mi->mounted = true;
return 0;

View File

@ -2690,9 +2690,16 @@ shared:
static int do_mount_root(struct mount_info *mi)
{
unsigned long mflags = mi->flags & (~MS_PROPAGATE);
if (restore_shared_options(mi, !mi->shared_id && !mi->master_id, mi->shared_id, mi->master_id))
return -1;
if (mflags && mount(NULL, service_mountpoint(mi), NULL, MS_REMOUNT | MS_BIND | mflags, NULL)) {
pr_perror("Unable to apply root mount options");
return -1;
}
return fetch_rt_stat(mi, service_mountpoint(mi));
}